home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / emacs / 19.22 / lisp / texinfmt.el < prev    next >
Lisp/Scheme  |  1993-11-19  |  114KB  |  3,031 lines

  1. ;;;; texinfmt.el
  2. ;;; Copyright (C) 1985, 1986, 1988,
  3. ;;;               1990, 1991, 1992, 1993  Free Software Foundation, Inc.
  4.  
  5. ;; Maintainer: Robert J. Chassell <bug-texinfo@prep.ai.mit.edu>
  6.  
  7. ;;; This file is part of GNU Emacs.
  8.  
  9. ;; GNU Emacs is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; GNU Emacs is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;; GNU General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  21. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. ;;; Code:
  24.  
  25. ;;; Emacs lisp functions to convert Texinfo files to Info files.
  26.  
  27. (defvar texinfmt-version "2.32 of 19 November 1993")
  28.  
  29. ;;; Variable definitions
  30.  
  31. (require 'texinfo)          ; So `texinfo-footnote-style' is defined.
  32. (require 'texnfo-upd)       ; So `texinfo-section-types-regexp' is defined.
  33.  
  34. (defvar texinfo-format-syntax-table nil)
  35.  
  36. (defvar texinfo-vindex)
  37. (defvar texinfo-findex)
  38. (defvar texinfo-cindex)
  39. (defvar texinfo-pindex)
  40. (defvar texinfo-tindex)
  41. (defvar texinfo-kindex)
  42. (defvar texinfo-last-node)
  43. (defvar texinfo-node-names)
  44. (defvar texinfo-enclosure-list)
  45.  
  46. (defvar texinfo-command-start)
  47. (defvar texinfo-command-end)
  48. (defvar texinfo-command-name)
  49. (defvar texinfo-defun-type)
  50. (defvar texinfo-last-node-pos)
  51. (defvar texinfo-stack)
  52. (defvar texinfo-short-index-cmds-alist)
  53. (defvar texinfo-short-index-format-cmds-alist)
  54. (defvar texinfo-format-filename)
  55. (defvar texinfo-footnote-number)
  56. (defvar texinfo-start-of-header)
  57. (defvar texinfo-end-of-header)
  58. (defvar texinfo-raisesections-alist)
  59. (defvar texinfo-lowersections-alist)
  60.  
  61. ;;; Syntax table
  62.  
  63. (if texinfo-format-syntax-table
  64.     nil
  65.   (setq texinfo-format-syntax-table (make-syntax-table))
  66.   (modify-syntax-entry ?\" " " texinfo-format-syntax-table)
  67.   (modify-syntax-entry ?\\ " " texinfo-format-syntax-table)
  68.   (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table)
  69.   (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table)
  70.   (modify-syntax-entry ?\[ "." texinfo-format-syntax-table)
  71.   (modify-syntax-entry ?\] "." texinfo-format-syntax-table)
  72.   (modify-syntax-entry ?\( "." texinfo-format-syntax-table)
  73.   (modify-syntax-entry ?\) "." texinfo-format-syntax-table)
  74.   (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table)
  75.   (modify-syntax-entry ?} "){" texinfo-format-syntax-table)
  76.   (modify-syntax-entry ?\' "." texinfo-format-syntax-table))
  77.  
  78.  
  79. ;;; Top level buffer and region formatting functions
  80.  
  81. ;;;###autoload
  82. (defun texinfo-format-buffer (&optional notagify)
  83.   "Process the current buffer as texinfo code, into an Info file.
  84. The Info file output is generated in a buffer visiting the Info file
  85. names specified in the @setfilename command.
  86.  
  87. Non-nil argument (prefix, if interactive) means don't make tag table
  88. and don't split the file if large.  You can use Info-tagify and
  89. Info-split to do these manually."
  90.   (interactive "P")
  91.   (let ((lastmessage "Formatting Info file..."))
  92.     (message lastmessage)
  93.     (texinfo-format-buffer-1)
  94.     (if notagify
  95.         nil
  96.       (if (> (buffer-size) 30000)
  97.           (progn
  98.             (message (setq lastmessage "Making tags table for Info file..."))
  99.             (Info-tagify)))
  100.       (if (> (buffer-size) 100000)
  101.           (progn
  102.             (message (setq lastmessage "Splitting Info file..."))
  103.             (Info-split))))
  104.     (message (concat lastmessage
  105.                      (if (interactive-p) "done.  Now save it." "done.")))))
  106.  
  107. (defvar texinfo-region-buffer-name "*Info Region*"
  108.   "*Name of the temporary buffer used by \\[texinfo-format-region].")
  109.  
  110. ;;;###autoload
  111. (defun texinfo-format-region (region-beginning region-end)
  112.   "Convert the current region of the Texinfo file to Info format.
  113. This lets you see what that part of the file will look like in Info.
  114. The command is bound to \\[texinfo-format-region].  The text that is
  115. converted to Info is stored in a temporary buffer."
  116.   (interactive "r")
  117.   (message "Converting region to Info format...")
  118.   (let (texinfo-command-start
  119.         texinfo-command-end
  120.         texinfo-command-name
  121.         texinfo-vindex
  122.         texinfo-findex
  123.         texinfo-cindex
  124.         texinfo-pindex
  125.         texinfo-tindex
  126.         texinfo-kindex
  127.         texinfo-stack
  128.         (texinfo-format-filename "")
  129.         texinfo-example-start
  130.         texinfo-last-node-pos
  131.         texinfo-last-node
  132.         texinfo-node-names
  133.         (texinfo-footnote-number 0)
  134.         last-input-buffer
  135.         (fill-column-for-info fill-column)
  136.         (input-buffer (current-buffer))
  137.         (input-directory default-directory)
  138.         (header-text "")
  139.         (header-beginning 1)
  140.         (header-end 1))
  141.     
  142. ;;; Copy lines between beginning and end of header lines, 
  143. ;;;    if any, or else copy the `@setfilename' line, if any.
  144.     (save-excursion
  145.         (save-restriction
  146.           (widen)
  147.           (goto-char (point-min))
  148.           (let ((search-end (save-excursion (forward-line 100) (point))))
  149.             (if (or
  150.                  ;; Either copy header text.
  151.                  (and 
  152.                   (prog1 
  153.                       (search-forward tex-start-of-header search-end t)
  154.                     (forward-line 1)
  155.                     ;; Mark beginning of header.
  156.                     (setq header-beginning (point)))
  157.                   (prog1 
  158.                       (search-forward tex-end-of-header nil t)
  159.                     (beginning-of-line)
  160.                     ;; Mark end of header
  161.                     (setq header-end (point))))
  162.                  ;; Or copy @filename line.
  163.                  (prog2
  164.                   (goto-char (point-min))
  165.                   (search-forward "@setfilename" search-end t)
  166.                   (beginning-of-line)
  167.                   (setq header-beginning (point))
  168.                   (forward-line 1)
  169.                   (setq header-end (point))))
  170.                 
  171.                 ;; Copy header  
  172.                 (setq header-text
  173.                       (buffer-substring
  174.                        (min header-beginning region-beginning)
  175.                        header-end))))))
  176.  
  177. ;;; Find a buffer to use.
  178.     (switch-to-buffer (get-buffer-create texinfo-region-buffer-name))
  179.     (erase-buffer)
  180.     ;; Insert the header into the buffer.
  181.     (insert header-text)
  182.     ;; Insert the region into the buffer.
  183.     (insert-buffer-substring
  184.      input-buffer
  185.      (max region-beginning header-end)
  186.      region-end)
  187.     ;; Make sure region ends in a newline.
  188.     (or (= (preceding-char) ?\n)
  189.         (insert "\n"))
  190.     
  191.     (goto-char (point-min))
  192.     (texinfo-mode)
  193.     (message "Converting region to Info format...")
  194.     (setq fill-column fill-column-for-info)
  195.     ;; Install a syntax table useful for scanning command operands.
  196.     (set-syntax-table texinfo-format-syntax-table)
  197.  
  198.     ;; Insert @include files so `texinfo-raise-lower-sections' can
  199.     ;; work on them without losing track of multiple
  200.     ;; @raise/@lowersections commands. 
  201.     (while (re-search-forward "^@include" nil t)
  202.       (setq texinfo-command-end (point))
  203.       (let ((filename (concat input-directory
  204.                               (texinfo-parse-line-arg))))
  205.         (beginning-of-line)
  206.         (delete-region (point) (save-excursion (forward-line 1) (point)))
  207.         (message "Reading included file: %s" filename)
  208.         (save-excursion
  209.           (save-restriction
  210.             (narrow-to-region
  211.              (point)
  212.              (+ (point) (car (cdr (insert-file-contents filename)))))
  213.             (goto-char (point-min))
  214.             ;; Remove `@setfilename' line from included file, if any,
  215.             ;; so @setfilename command not duplicated.
  216.             (if (re-search-forward 
  217.                  "^@setfilename" (save-excursion (forward-line 100) (point)) t)
  218.                 (progn
  219.                   (beginning-of-line)
  220.                   (delete-region
  221.                    (point) (save-excursion (forward-line 1) (point)))))))))
  222.  
  223.     ;; Raise or lower level of each section, if necessary.
  224.     (goto-char (point-min))
  225.     (texinfo-raise-lower-sections)
  226.     ;; Append @refill to appropriate paragraphs for filling.
  227.     (goto-char (point-min))
  228.     (texinfo-append-refill)
  229.     ;; If the region includes the effective end of the data,
  230.     ;; discard everything after that.
  231.     (goto-char (point-max))
  232.     (if (re-search-backward "^@bye" nil t)
  233.         (delete-region (point) (point-max)))
  234.     ;; Make sure buffer ends in a newline.
  235.     (or (= (preceding-char) ?\n)
  236.         (insert "\n"))
  237.     ;; Don't use a previous value of texinfo-enclosure-list.
  238.     (setq texinfo-enclosure-list nil)
  239.  
  240.     (goto-char (point-min))
  241.     (if (looking-at "\\\\input[ \t]+texinfo")
  242.         (delete-region (point) (save-excursion (forward-line 1) (point))))
  243.  
  244.     ;; Insert Info region title text.
  245.     (goto-char (point-min))
  246.     (if (search-forward 
  247.          "@setfilename" (save-excursion (forward-line 100) (point)) t)
  248.         (progn
  249.           (setq texinfo-command-end (point))
  250.           (beginning-of-line)
  251.           (setq texinfo-command-start (point))
  252.           (let ((arg (texinfo-parse-arg-discard)))
  253.             (insert " "
  254.               texinfo-region-buffer-name
  255.               " buffer for:  `") 
  256.             (insert (file-name-nondirectory (expand-file-name arg)))
  257.             (insert "',        -*-Text-*-\n")))
  258.       ;; Else no `@setfilename' line
  259.       (insert " "
  260.               texinfo-region-buffer-name
  261.               " buffer                       -*-Text-*-\n"))
  262.     (insert "produced by `texinfo-format-region'\n"
  263.             "from a region in: "
  264.             (if (buffer-file-name input-buffer)
  265.                   (concat "`"
  266.                           (file-name-sans-versions
  267.                            (file-name-nondirectory
  268.                             (buffer-file-name input-buffer)))
  269.                           "'")
  270.                 (concat "buffer `" (buffer-name input-buffer) "'"))
  271.               "\nusing `texinfmt.el' version "
  272.               texinfmt-version
  273.               ".\n\n")
  274.  
  275.     ;; Now convert for real.
  276.     (goto-char (point-min))
  277.     (texinfo-format-scan)
  278.     (goto-char (point-min))
  279.     
  280.     (message "Done.")))
  281.  
  282.  
  283. ;;; Primary internal formatting function for the whole buffer.
  284.  
  285. (defun texinfo-format-buffer-1 ()
  286.   (let (texinfo-format-filename
  287.         texinfo-example-start
  288.         texinfo-command-start
  289.         texinfo-command-end
  290.         texinfo-command-name
  291.         texinfo-last-node
  292.         texinfo-last-node-pos
  293.         texinfo-vindex
  294.         texinfo-findex
  295.         texinfo-cindex
  296.         texinfo-pindex
  297.         texinfo-tindex
  298.         texinfo-kindex
  299.         texinfo-stack
  300.         texinfo-node-names
  301.         (texinfo-footnote-number 0)
  302.         last-input-buffer
  303.         outfile
  304.         (fill-column-for-info fill-column)
  305.         (input-buffer (current-buffer))
  306.         (input-directory default-directory))
  307.     (setq texinfo-enclosure-list nil)
  308.     (save-excursion
  309.       (goto-char (point-min))
  310.       (or (search-forward "@setfilename" nil t)
  311.           (error "Texinfo file needs an `@setfilename FILENAME' line."))
  312.       (setq texinfo-command-end (point))
  313.       (setq outfile (texinfo-parse-line-arg)))
  314.     (find-file outfile)
  315.     (texinfo-mode)
  316.     (setq fill-column fill-column-for-info)
  317.     (set-syntax-table texinfo-format-syntax-table)
  318.     (erase-buffer)
  319.     (insert-buffer-substring input-buffer)
  320.     (message "Converting %s to Info format..." (buffer-name input-buffer))
  321.     
  322.     ;; Insert @include files so `texinfo-raise-lower-sections' can
  323.     ;; work on them without losing track of multiple
  324.     ;; @raise/@lowersections commands. 
  325.     (goto-char (point-min))
  326.     (while (re-search-forward "^@include" nil t)
  327.       (setq texinfo-command-end (point))
  328.       (let ((filename (concat input-directory
  329.                               (texinfo-parse-line-arg))))
  330.         (beginning-of-line)
  331.         (delete-region (point) (save-excursion (forward-line 1) (point)))
  332.         (message "Reading included file: %s" filename)
  333.         (save-excursion
  334.           (save-restriction
  335.             (narrow-to-region
  336.              (point)
  337.              (+ (point) (car (cdr (insert-file-contents filename)))))
  338.             (goto-char (point-min))
  339.             ;; Remove `@setfilename' line from included file, if any,
  340.             ;; so @setfilename command not duplicated.
  341.             (if (re-search-forward 
  342.                  "^@setfilename"
  343.                  (save-excursion (forward-line 100) (point)) t)
  344.                 (progn
  345.                   (beginning-of-line)
  346.                   (delete-region
  347.                    (point) (save-excursion (forward-line 1) (point)))))))))
  348.     ;; Raise or lower level of each section, if necessary.
  349.     (goto-char (point-min))
  350.     (texinfo-raise-lower-sections)
  351.     ;; Append @refill to appropriate paragraphs
  352.     (goto-char (point-min))
  353.     (texinfo-append-refill)
  354.     (goto-char (point-min))
  355.     (search-forward "@setfilename")
  356.     (beginning-of-line)
  357.     (delete-region (point-min) (point))
  358.     ;; Remove @bye at end of file, if it is there.
  359.     (goto-char (point-max))
  360.     (if (search-backward "@bye" nil t)
  361.         (delete-region (point) (point-max)))
  362.     ;; Make sure buffer ends in a newline.
  363.     (or (= (preceding-char) ?\n)
  364.         (insert "\n"))
  365.     ;; Scan the whole buffer, converting to Info format.
  366.     (texinfo-format-scan)
  367.     ;; Return data for indices.
  368.     (goto-char (point-min))
  369.     (list outfile
  370.           texinfo-vindex texinfo-findex texinfo-cindex
  371.           texinfo-pindex texinfo-tindex texinfo-kindex)))
  372.  
  373.  
  374. ;;; Perform non-@-command file conversions: quotes and hyphens
  375.  
  376. (defun texinfo-format-convert (min max)
  377.   ;; Convert left and right quotes to typewriter font quotes.
  378.   (goto-char min)
  379.   (while (search-forward "``" max t)
  380.     (replace-match "\""))
  381.   (goto-char min)
  382.   (while (search-forward "''" max t)
  383.     (replace-match "\""))
  384.   ;; Convert three hyphens in a row to two.
  385.   (goto-char min)
  386.   (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t)
  387.     (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning
  388.     2)))))
  389.  
  390.  
  391. ;;; Handle paragraph filling
  392.  
  393. (defvar texinfo-no-refill-regexp
  394.   "^@\\(example\\|smallexample\\|lisp\\|smalllisp\\|display\\|format\\|flushleft\\|flushright\\|menu\\|titlepage\\|iftex\\|tex\\)"
  395.   "Regexp specifying environments in which paragraphs are not filled.")
  396.  
  397. (defvar texinfo-part-of-para-regexp
  398.   "^@\\(b{\\|bullet{\\|cite{\\|code{\\|emph{\\|equiv{\\|error{\\|expansion{\\|file{\\|i{\\|inforef{\\|kbd{\\|key{\\|lisp{\\|minus{\\|point{\\|print{\\|pxref{\\|r{\\|ref{\\|result{\\|samp{\\|sc{\\|t{\\|TeX{\\|today{\\|var{\\|w{\\|xref{\\)"
  399.   "Regexp specifying @-commands found within paragraphs.")
  400.  
  401. (defun texinfo-append-refill ()
  402.   "Append @refill at end of each paragraph that should be filled.
  403. Do not append @refill to paragraphs within @example and similar environments.  
  404. Do not append @refill to paragraphs containing @w{TEXT} or @*."
  405.  
  406.   ;; It is necessary to append @refill before other processing because
  407.   ;; the other processing removes information that tells Texinfo
  408.   ;; whether the text should or should not be filled.
  409.   
  410.   (while (< (point) (point-max))
  411.     (let ((refill-blank-lines "^[ \t\n]*$")
  412.           (case-fold-search nil))       ; Don't confuse @TeX and @tex....
  413.       (beginning-of-line)
  414.       ;; 1. Skip over blank lines;
  415.       ;;    skip over lines beginning with @-commands, 
  416.       ;;    but do not skip over lines
  417.       ;;      that are no-refill environments such as @example or
  418.       ;;      that begin with within-paragraph @-commands such as @code.
  419.       (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines))
  420.                   (not (looking-at 
  421.                         (concat
  422.                          "\\(" 
  423.                          texinfo-no-refill-regexp
  424.                          "\\|" 
  425.                          texinfo-part-of-para-regexp
  426.                          "\\)")))
  427.                   (< (point) (point-max)))
  428.         (forward-line 1))
  429.       ;; 2. Skip over @example and similar no-refill environments.
  430.       (if (looking-at texinfo-no-refill-regexp)
  431.           (let ((environment
  432.                  (buffer-substring (match-beginning 1) (match-end 1))))
  433.             (progn (re-search-forward (concat "^@end " environment) nil t)
  434.                    (forward-line 1)))
  435.         ;; 3. Do not refill a paragraph containing @w or @*
  436.         (if  (or
  437.               (>= (point) (point-max))
  438.               (re-search-forward
  439.                "@w{\\|@\\*" (save-excursion (forward-paragraph) (point)) t))
  440.             ;; Go to end of paragraph and do nothing.
  441.             (forward-paragraph) 
  442.           ;; 4. Else go to end of paragraph and insert @refill
  443.           (forward-paragraph)
  444.           (forward-line -1)
  445.           (end-of-line)
  446.           (delete-region
  447.            (point)
  448.            (save-excursion (skip-chars-backward " \t") (point)))
  449.           ;; `looking-at-backward' not available in v. 18.57
  450.           ;; (if (not (looking-at-backward "@refill\\|@bye")) ;)
  451.           (if (not (re-search-backward
  452.                     "@refill\\|@bye"
  453.                     (save-excursion (beginning-of-line) (point))
  454.                     t))
  455.               (insert "@refill"))
  456.           (forward-line 1))))))
  457.  
  458.  
  459. ;;; Handle `@raisesections' and `@lowersections' commands
  460.  
  461. ;; These commands change the hierarchical level of chapter structuring
  462. ;; commands. 
  463. ;;    
  464. ;; @raisesections changes @subsection to @section,
  465. ;;                        @section    to @chapter,
  466. ;;                        etc.
  467. ;;
  468. ;; @lowersections changes @chapter    to @section
  469. ;;                        @subsection to @subsubsection,
  470. ;;                        etc.
  471. ;;
  472. ;; An @raisesections/@lowersections command changes only those
  473. ;; structuring commands that follow the @raisesections/@lowersections
  474. ;; command.
  475. ;;
  476. ;; Repeated @raisesections/@lowersections continue to raise or lower
  477. ;; the heading level.
  478. ;; 
  479. ;; An @lowersections command cancels an @raisesections command, and
  480. ;; vice versa.
  481. ;;
  482. ;; You cannot raise or lower "beyond" chapters or subsubsections, but
  483. ;; trying to do so does not elicit an error---you just get more
  484. ;; headings that mean the same thing as you keep raising or lowering
  485. ;; (for example, after a single @raisesections, both @chapter and
  486. ;; @section produce chapter headings).
  487.  
  488. (defun texinfo-raise-lower-sections ()
  489.   "Raise or lower the hierarchical level of chapters, sections, etc. 
  490.  
  491. This function acts according to `@raisesections' and `@lowersections'
  492. commands in the Texinfo file.
  493.  
  494. For example, an `@lowersections' command is useful if you wish to
  495. include what is written as an outer or standalone Texinfo file in
  496. another Texinfo file as an inner, included file.  The `@lowersections'
  497. command changes chapters to sections, sections to subsections and so
  498. on.
  499.  
  500. @raisesections changes @subsection to @section,
  501.                        @section    to @chapter,
  502.                        @heading    to @chapheading,
  503.                        etc.
  504.  
  505. @lowersections changes @chapter    to @section,
  506.                        @subsection to @subsubsection,
  507.                        @heading    to @subheading,
  508.                        etc.
  509.  
  510. An `@raisesections' or `@lowersections' command changes only those
  511. structuring commands that follow the `@raisesections' or
  512. `@lowersections' command.
  513.  
  514. An `@lowersections' command cancels an `@raisesections' command, and
  515. vice versa.
  516.  
  517. Repeated use of the commands continue to raise or lower the hierarchical
  518. level a step at a time.
  519.  
  520. An attempt to raise above `chapters' reproduces chapter commands; an
  521. attempt to lower below subsubsections reproduces subsubsection
  522. commands."
  523.   
  524.   ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el';
  525.   ;; it is a regexp matching chapter, section, other headings
  526.   ;; (but not the top node).
  527.  
  528.   (let (type (level 0))
  529.     (while 
  530.         (re-search-forward
  531.          (concat
  532.           "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\("
  533.           texinfo-section-types-regexp
  534.           "\\)\\)")
  535.          nil t)
  536.       (beginning-of-line)
  537.       (save-excursion (setq type (read (current-buffer))))
  538.       (cond 
  539.        
  540.        ;; 1. Increment level
  541.        ((eq type '@raisesections)
  542.         (setq level (1+ level))
  543.         (delete-region
  544.          (point) (save-excursion (forward-line 1) (point))))
  545.        
  546.        ;; 2. Decrement level
  547.        ((eq type '@lowersections)
  548.         (setq level (1- level))
  549.         (delete-region
  550.          (point) (save-excursion (forward-line 1) (point))))
  551.        
  552.        ;; Now handle structuring commands
  553.        ((cond
  554.          
  555.          ;; 3. Raise level when positive
  556.          ((> level 0)
  557.           (let ((count level)
  558.                 (new-level type))
  559.             (while (> count 0)
  560.               (setq new-level
  561.                     (cdr (assq new-level texinfo-raisesections-alist)))
  562.               (setq count (1- count)))
  563.             (kill-word 1)
  564.             (insert (symbol-name new-level))))
  565.          
  566.          ;; 4. Do nothing except move point when level is zero
  567.          ((= level 0) (forward-line 1))
  568.          
  569.          ;; 5. Lower level when positive
  570.          ((< level 0)
  571.           (let ((count level)
  572.                 (new-level type))
  573.             (while (< count 0)
  574.               (setq new-level
  575.                     (cdr (assq new-level texinfo-lowersections-alist)))
  576.               (setq count (1+ count)))
  577.             (kill-word 1)
  578.             (insert (symbol-name new-level))))))))))
  579.  
  580. (defvar texinfo-raisesections-alist
  581.   '((@chapter . @chapter)             ; Cannot go higher
  582.     (@unnumbered . @unnumbered)
  583.  
  584.     (@majorheading . @majorheading)
  585.     (@chapheading . @chapheading)
  586.     (@appendix . @appendix)
  587.     
  588.     (@section . @chapter)
  589.     (@unnumberedsec . @unnumbered)
  590.     (@heading . @chapheading)
  591.     (@appendixsec . @appendix)
  592.     
  593.     (@subsection . @section)
  594.     (@unnumberedsubsec . @unnumberedsec)
  595.     (@subheading . @heading)
  596.     (@appendixsubsec . @appendixsec)
  597.     
  598.     (@subsubsection . @subsection)
  599.     (@unnumberedsubsubsec . @unnumberedsubsec)
  600.     (@subsubheading . @subheading)
  601.     (@appendixsubsubsec . @appendixsubsec))
  602.   "*An alist of next higher levels for chapters, sections. etc.
  603. For example, section to chapter, subsection to section.
  604. Used by `texinfo-raise-lower-sections'.
  605. The keys specify types of section; the values correspond to the next
  606. higher types.")
  607.  
  608. (defvar texinfo-lowersections-alist
  609.   '((@chapter . @section)  
  610.     (@unnumbered . @unnumberedsec)
  611.     (@majorheading . @heading)
  612.     (@chapheading . @heading)
  613.     (@appendix . @appendixsec)
  614.     
  615.     (@section . @subsection)
  616.     (@unnumberedsec . @unnumberedsubsec)
  617.     (@heading . @subheading)
  618.     (@appendixsec . @appendixsubsec)
  619.     
  620.     (@subsection . @subsubsection)
  621.     (@unnumberedsubsec . @unnumberedsubsubsec)
  622.     (@subheading . @subsubheading)
  623.     (@appendixsubsec . @appendixsubsubsec)
  624.     
  625.     (@subsubsection . @subsubsection) ; Cannot go lower.
  626.     (@unnumberedsubsubsec . @unnumberedsubsubsec)
  627.     (@subsubheading . @subsubheading)
  628.     (@appendixsubsubsec . @appendixsubsubsec))
  629.   "*An alist of next lower levels for chapters, sections. etc.
  630. For example, chapter to section, section to subsection.
  631. Used by `texinfo-raise-lower-sections'.
  632. The keys specify types of section; the values correspond to the next
  633. lower types.")
  634.  
  635.  
  636. ;;; Perform those texinfo-to-info conversions that apply to the whole input
  637. ;;; uniformly.
  638.  
  639. (defun texinfo-format-scan ()
  640.   (texinfo-format-convert (point-min) (point-max))
  641.   ;; Scan for @-commands.
  642.   (goto-char (point-min))
  643.   (while (search-forward "@" nil t)
  644.     (if (looking-at "[@{}'` *]")
  645.         ;; Handle a few special @-followed-by-one-char commands.
  646.         (if (= (following-char) ?*)
  647.             (progn
  648.               ;; remove command
  649.               (delete-region (1- (point)) (1+ (point)))
  650.               ;; insert return if not at end of line;
  651.               ;; else line is already broken.
  652.               (if (not (= (following-char) ?\n))
  653.                   (insert ?\n)))      
  654.           ;; The other characters are simply quoted.  Delete the @.
  655.           (delete-char -1)
  656.           (forward-char 1))
  657.       ;; @ is followed by a command-word; find the end of the word.
  658.       (setq texinfo-command-start (1- (point)))
  659.       (if (= (char-syntax (following-char)) ?w)
  660.           (forward-word 1)
  661.         (forward-char 1))
  662.       (setq texinfo-command-end (point))
  663.       ;; Call the handler for this command.
  664.       (setq texinfo-command-name
  665.             (intern (buffer-substring
  666.              (1+ texinfo-command-start) texinfo-command-end)))
  667.       (let ((enclosure-type
  668.              (assoc
  669.               (symbol-name texinfo-command-name)
  670.               texinfo-enclosure-list)))
  671.         (if enclosure-type
  672.             (progn
  673.               (insert
  674.                (car (car (cdr enclosure-type))) 
  675.                (texinfo-parse-arg-discard)
  676.                (car (cdr (car (cdr enclosure-type)))))
  677.               (goto-char texinfo-command-start))
  678.           (let ((cmd (get texinfo-command-name 'texinfo-format)))
  679.             (if cmd (funcall cmd) (texinfo-unsupported)))))))
  680.   
  681.   (cond (texinfo-stack
  682.          (goto-char (nth 2 (car texinfo-stack)))
  683.          (error "Unterminated @%s" (car (car texinfo-stack))))))
  684.  
  685. (put 'begin 'texinfo-format 'texinfo-format-begin)
  686. (defun texinfo-format-begin ()
  687.   (texinfo-format-begin-end 'texinfo-format))
  688.  
  689. (put 'end 'texinfo-format 'texinfo-format-end)
  690. (defun texinfo-format-end ()
  691.   (texinfo-format-begin-end 'texinfo-end))
  692.  
  693. (defun texinfo-format-begin-end (prop)
  694.   (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
  695.   (let ((cmd (get texinfo-command-name prop)))
  696.     (if cmd (funcall cmd)
  697.       (texinfo-unsupported))))
  698.  
  699. ;;; Parsing functions
  700.  
  701. (defun texinfo-parse-line-arg ()
  702.   (goto-char texinfo-command-end)
  703.   (let ((start (point)))
  704.     (cond ((looking-at " ")
  705.            (skip-chars-forward " ")
  706.            (setq start (point))
  707.            (end-of-line)
  708.            (skip-chars-backward " ")
  709.            (delete-region (point) (progn (end-of-line) (point)))
  710.            (setq texinfo-command-end (1+ (point))))
  711.           ((looking-at "{")
  712.            (setq start (1+ (point)))
  713.            (forward-list 1)
  714.            (setq texinfo-command-end (point))
  715.            (forward-char -1))
  716.           (t
  717.            (error "Invalid texinfo command arg format")))
  718.     (prog1 (buffer-substring start (point))
  719.            (if (eolp) (forward-char 1)))))
  720.  
  721. (defun texinfo-parse-expanded-arg ()
  722.   (goto-char texinfo-command-end)
  723.   (let ((start (point))
  724.         marker)
  725.     (cond ((looking-at " ")
  726.            (skip-chars-forward " ")
  727.            (setq start (point))
  728.            (end-of-line)
  729.            (setq texinfo-command-end (1+ (point))))
  730.           ((looking-at "{")
  731.            (setq start (1+ (point)))
  732.            (forward-list 1)
  733.            (setq texinfo-command-end (point))
  734.            (forward-char -1))
  735.           (t
  736.            (error "Invalid texinfo command arg format")))
  737.     (setq marker (move-marker (make-marker) texinfo-command-end))
  738.     (texinfo-format-expand-region start (point))
  739.     (setq texinfo-command-end (marker-position marker))
  740.     (move-marker marker nil)
  741.     (prog1 (buffer-substring start (point))
  742.            (if (eolp) (forward-char 1)))))
  743.  
  744. (defun texinfo-format-expand-region (start end)
  745.   (save-restriction
  746.     (narrow-to-region start end)
  747.     (let (texinfo-command-start
  748.           texinfo-command-end
  749.           texinfo-command-name
  750.           texinfo-stack)
  751.       (texinfo-format-scan))
  752.     (goto-char (point-max))))
  753.  
  754. (defun texinfo-parse-arg-discard ()
  755.   (prog1 (texinfo-parse-line-arg)
  756.          (texinfo-discard-command)))
  757.  
  758. (defun texinfo-discard-command ()
  759.   (delete-region texinfo-command-start texinfo-command-end))
  760.  
  761. (defun texinfo-optional-braces-discard ()
  762.   "Discard braces following command, if any."
  763.   (goto-char texinfo-command-end)
  764.   (let ((start (point)))
  765.     (cond ((looking-at "[ \t]*\n"))     ; do nothing
  766.           ((looking-at "{")             ; remove braces, if any
  767.            (forward-list 1)
  768.            (setq texinfo-command-end (point)))
  769.           (t
  770.            (error
  771.             "Invalid `texinfo-optional-braces-discard' format \(need braces?\)")))
  772.     (delete-region texinfo-command-start texinfo-command-end)))
  773.  
  774. (defun texinfo-format-parse-line-args ()
  775.   (let ((start (1- (point)))
  776.         next beg end
  777.         args)
  778.     (skip-chars-forward " ")
  779.     (while (not (eolp))
  780.       (setq beg (point))
  781.       (re-search-forward "[\n,]")
  782.       (setq next (point))
  783.       (if (bolp) (setq next (1- next)))
  784.       (forward-char -1)
  785.       (skip-chars-backward " ")
  786.       (setq end (point))
  787.       (setq args (cons (if (> end beg) (buffer-substring beg end))
  788.                        args))
  789.       (goto-char next)
  790.       (skip-chars-forward " "))
  791.     (if (eolp) (forward-char 1))
  792.     (setq texinfo-command-end (point))
  793.     (nreverse args)))
  794.  
  795. (defun texinfo-format-parse-args ()
  796.   (let ((start (1- (point)))
  797.         next beg end
  798.         args)
  799.     (search-forward "{")
  800.     (save-excursion
  801.       (texinfo-format-expand-region 
  802.        (point)
  803.        (save-excursion (up-list 1) (1- (point)))))
  804.     ;; The following does not handle cross references of the form:
  805.     ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
  806.     ;; re-search-forward finds the first right brace after the second
  807.     ;; comma. 
  808.     (while (/= (preceding-char) ?\})
  809.       (skip-chars-forward " \t\n")
  810.       (setq beg (point))
  811.       (re-search-forward "[},]")
  812.       (setq next (point))
  813.       (forward-char -1)
  814.       (skip-chars-backward " \t\n")
  815.       (setq end (point))
  816.       (cond ((< beg end)
  817.              (goto-char beg)
  818.              (while (search-forward "\n" end t)
  819.                (replace-match " "))))
  820.       (setq args (cons (if (> end beg) (buffer-substring beg end))
  821.                        args))
  822.       (goto-char next))
  823.     (if (eolp) (forward-char 1))
  824.     (setq texinfo-command-end (point))
  825.     (nreverse args)))
  826.  
  827. (defun texinfo-format-parse-defun-args ()
  828.   (goto-char texinfo-command-end)
  829.   (let ((start (point)))
  830.     (end-of-line)
  831.     (setq texinfo-command-end (1+ (point)))
  832.     (let ((marker (move-marker (make-marker) texinfo-command-end)))
  833.       (texinfo-format-expand-region start (point))
  834.       (setq texinfo-command-end (marker-position marker))
  835.       (move-marker marker nil))
  836.     (goto-char start)
  837.     (let ((args '())
  838.           beg end)
  839.       (skip-chars-forward " ")
  840.       (while (not (eolp))
  841.         (cond ((looking-at "{")
  842.                (setq beg (1+ (point)))
  843.                (forward-list 1)
  844.                (setq end (1- (point))))
  845.               (t
  846.                (setq beg (point))
  847.                (re-search-forward "[\n ]")
  848.                (forward-char -1)
  849.                (setq end (point))))
  850.         (setq args (cons (buffer-substring beg end) args))
  851.         (skip-chars-forward " "))
  852.       (forward-char 1)
  853.       (nreverse args))))
  854.  
  855. (defun texinfo-discard-line ()
  856.   (goto-char texinfo-command-end)
  857.   (skip-chars-forward " \t")
  858.   (or (eolp)
  859.       (error "Extraneous text at end of command line."))
  860.   (goto-char texinfo-command-start)
  861.   (or (bolp)
  862.       (error "Extraneous text at beginning of command line."))
  863.   (delete-region (point) (progn (forward-line 1) (point))))
  864.  
  865. (defun texinfo-discard-line-with-args ()
  866.   (goto-char texinfo-command-start)
  867.   (delete-region (point) (progn (forward-line 1) (point))))
  868.  
  869.  
  870. ;;; @setfilename
  871.  
  872. ;; Only `texinfo-format-buffer' handles @setfilename with this
  873. ;; definition; `texinfo-format-region' handles @setfilename, if any,
  874. ;; specially. 
  875. (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
  876. (defun texinfo-format-setfilename ()
  877.   (let ((arg (texinfo-parse-arg-discard)))
  878.     (message "Formatting Info file: %s" arg)
  879.     (setq texinfo-format-filename
  880.           (file-name-nondirectory (expand-file-name arg)))
  881.     (insert "Info file: "
  882.             texinfo-format-filename ",    -*-Text-*-\n"
  883.             ;; Date string removed so that regression testing is easier.
  884.             ;; "produced on "
  885.             ;; (substring (current-time-string) 8 10) " "
  886.             ;; (substring (current-time-string) 4 7) " "
  887.             ;; (substring (current-time-string) -4)  " "
  888.             "produced by `texinfo-format-buffer'\n"
  889.             "from file"
  890.             (if (buffer-file-name input-buffer)
  891.                 (concat " `"
  892.                         (file-name-sans-versions
  893.                          (file-name-nondirectory
  894.                           (buffer-file-name input-buffer)))
  895.                         "'")
  896.               (concat "buffer `" (buffer-name input-buffer) "'"))
  897.             "\nusing `texinfmt.el' version "
  898.             texinfmt-version
  899.             ".\n\n")))
  900.  
  901. ;;; @node, @menu
  902.  
  903. (put 'node 'texinfo-format 'texinfo-format-node)
  904. (put 'nwnode 'texinfo-format 'texinfo-format-node)
  905. (defun texinfo-format-node ()
  906.   (let* ((args (texinfo-format-parse-line-args))
  907.          (name (nth 0 args))
  908.          (next (nth 1 args))
  909.          (prev (nth 2 args))
  910.          (up (nth 3 args)))
  911.     (texinfo-discard-command)
  912.     (setq texinfo-last-node name)
  913.     (let ((tem (downcase name)))
  914.       (if (assoc tem texinfo-node-names)
  915.           (error "Duplicate node name: %s" name)
  916.         (setq texinfo-node-names (cons (list tem) texinfo-node-names))))
  917.     (setq texinfo-footnote-number 0)
  918.     (or (bolp)
  919.         (insert ?\n))
  920.     (insert "\^_\nFile: " texinfo-format-filename
  921.             ", Node: " name)
  922.     (if next
  923.         (insert ", Next: " next))
  924.     (if prev
  925.         (insert ", Prev: " prev))
  926.     (if up
  927.         (insert ", Up: " up))
  928.     (insert ?\n)
  929.     (setq texinfo-last-node-pos (point))))
  930.  
  931. (put 'menu 'texinfo-format 'texinfo-format-menu)
  932. (defun texinfo-format-menu ()
  933.   (texinfo-discard-line)
  934.   (insert "* Menu:\n\n"))
  935.  
  936. (put 'menu 'texinfo-end 'texinfo-discard-command)
  937.  
  938.  
  939. ;;; Cross references
  940.  
  941. ; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
  942. ; -> *Note FNAME: (FILE)NODE
  943. ;   If FILE is missing,
  944. ;    *Note FNAME: NODE
  945. ;   If FNAME is empty and NAME is present
  946. ;    *Note NAME: Node
  947. ;   If both NAME and FNAME are missing
  948. ;    *Note NODE::
  949. ;   texinfo ignores the DOCUMENT argument.
  950. ; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
  951. ;   If FILE is specified, (FILE)NODE is used for xrefs.
  952. ;   If fifth argument DOCUMENT is specified, produces
  953. ;    See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
  954. ;    of DOCUMENT
  955.  
  956. ; @ref             a reference that does not put `See' or `see' in
  957. ;                  the hardcopy and is the same as @xref in Info
  958. (put 'ref 'texinfo-format 'texinfo-format-xref)
  959.  
  960. (put 'xref 'texinfo-format 'texinfo-format-xref)
  961. (defun texinfo-format-xref ()
  962.   (let ((args (texinfo-format-parse-args)))
  963.     (texinfo-discard-command)
  964.     (insert "*Note ")
  965.     (let ((fname (or (nth 1 args) (nth 2 args))))
  966.       (if (null (or fname (nth 3 args)))
  967.           (insert (car args) "::")
  968.         (insert (or fname (car args)) ": ")
  969.         (if (nth 3 args)
  970.             (insert "(" (nth 3 args) ")"))
  971.         (insert (car args))))))
  972.  
  973. (put 'pxref 'texinfo-format 'texinfo-format-pxref)
  974. (defun texinfo-format-pxref ()
  975.   (texinfo-format-xref)
  976.   (or (save-excursion
  977.         (forward-char -2)
  978.         (looking-at "::"))
  979.       (insert ".")))
  980.  
  981. ;@inforef{NODE, FNAME, FILE}
  982. ;Like @xref{NODE, FNAME,,FILE} in texinfo.
  983. ;In Tex, generates "See Info file FILE, node NODE"
  984. (put 'inforef 'texinfo-format 'texinfo-format-inforef)
  985. (defun texinfo-format-inforef ()
  986.   (let ((args (texinfo-format-parse-args)))
  987.     (texinfo-discard-command)
  988.     (if (nth 1 args)
  989.         (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
  990.       (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
  991.  
  992.  
  993. ;;; Section headings
  994.  
  995. (put 'majorheading 'texinfo-format 'texinfo-format-chapter)
  996. (put 'chapheading 'texinfo-format 'texinfo-format-chapter)
  997. (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
  998. (put 'chapter 'texinfo-format 'texinfo-format-chapter)
  999. (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
  1000. (put 'appendix 'texinfo-format 'texinfo-format-chapter)
  1001. (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
  1002. (put 'top 'texinfo-format 'texinfo-format-chapter)
  1003. (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
  1004. (defun texinfo-format-chapter ()
  1005.   (texinfo-format-chapter-1 ?*))
  1006.  
  1007. (put 'heading 'texinfo-format 'texinfo-format-section)
  1008. (put 'isection 'texinfo-format 'texinfo-format-section)
  1009. (put 'section 'texinfo-format 'texinfo-format-section)
  1010. (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
  1011. (put 'appendixsection 'texinfo-format 'texinfo-format-section)
  1012. (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
  1013. (put 'appendixsec 'texinfo-format 'texinfo-format-section)
  1014. (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
  1015. (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
  1016. (defun texinfo-format-section ()
  1017.   (texinfo-format-chapter-1 ?=))
  1018.  
  1019. (put 'subheading 'texinfo-format 'texinfo-format-subsection)
  1020. (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
  1021. (put 'subsection 'texinfo-format 'texinfo-format-subsection)
  1022. (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
  1023. (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
  1024. (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
  1025. (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
  1026. (defun texinfo-format-subsection ()
  1027.   (texinfo-format-chapter-1 ?-))
  1028.  
  1029. (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection)
  1030. (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
  1031. (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
  1032. (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
  1033. (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
  1034. (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
  1035. (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
  1036. (defun texinfo-format-subsubsection ()
  1037.   (texinfo-format-chapter-1 ?.))
  1038.  
  1039. (defun texinfo-format-chapter-1 (belowchar)
  1040.   (let ((arg (texinfo-parse-arg-discard)))
  1041.     (message "Formatting: %s ... " arg)   ; So we can see where we are.
  1042.     (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
  1043.     (forward-line -2)))
  1044.  
  1045. (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
  1046. (defun texinfo-format-sectionpad ()
  1047.   (let ((str (texinfo-parse-arg-discard)))
  1048.     (forward-char -1)
  1049.     (let ((column (current-column)))
  1050.       (forward-char 1)
  1051.       (while (> column 0)
  1052.         (insert str)
  1053.         (setq column (1- column))))
  1054.     (insert ?\n)))
  1055.  
  1056.  
  1057. ;;; Space controling commands:  @. and @:   
  1058. (put '\. 'texinfo-format 'texinfo-format-\.)
  1059. (defun texinfo-format-\. ()
  1060.   (texinfo-discard-command)
  1061.   (insert "."))
  1062.  
  1063. (put '\: 'texinfo-format 'texinfo-format-\:)
  1064. (defun texinfo-format-\: ()
  1065.   (texinfo-discard-command))
  1066.  
  1067.  
  1068. ;;; @center, @sp, and @br
  1069.  
  1070. (put 'center 'texinfo-format 'texinfo-format-center)
  1071. (defun texinfo-format-center ()
  1072.   (let ((arg (texinfo-parse-expanded-arg)))
  1073.     (texinfo-discard-command)
  1074.     (insert arg)
  1075.     (insert ?\n)
  1076.     (save-restriction
  1077.       (goto-char (1- (point)))
  1078.       (let ((indent-tabs-mode nil))
  1079.         (center-line)))))
  1080.  
  1081. (put 'sp 'texinfo-format 'texinfo-format-sp)
  1082. (defun texinfo-format-sp ()
  1083.   (let* ((arg (texinfo-parse-arg-discard))
  1084.          (num (read arg)))
  1085.     (insert-char ?\n num)))
  1086.  
  1087. (put 'br 'texinfo-format 'texinfo-format-paragraph-break)
  1088. (defun texinfo-format-paragraph-break ()
  1089.   "Force a paragraph break.
  1090. If used within a line, follow `@br' with braces."
  1091.   (texinfo-optional-braces-discard)
  1092.   ;; insert one return if at end of line;
  1093.   ;; else insert two returns, to generate a blank line.
  1094.   (if (= (following-char) ?\n)
  1095.       (insert ?\n)
  1096.     (insert-char ?\n 2)))
  1097.  
  1098.  
  1099. ;;; @footnote  and  @footnotestyle
  1100.  
  1101. ; In Texinfo, footnotes are created with the `@footnote' command.
  1102. ; This command is followed immediately by a left brace, then by the text of
  1103. ; the footnote, and then by a terminating right brace.  The
  1104. ; template for a footnote is:
  1105. ;      @footnote{TEXT}
  1106. ;
  1107. ; Info has two footnote styles:
  1108. ;    * In the End of node style, all the footnotes for a single node
  1109. ;      are placed at the end of that node.  The footnotes are
  1110. ;      separated from the rest of the node by a line of dashes with
  1111. ;      the word `Footnotes' within it.
  1112. ;    * In the Separate node style, all the footnotes for a single node
  1113. ;      are placed in an automatically constructed node of their own.
  1114.  
  1115. ; Footnote style is specified by the @footnotestyle command, either
  1116. ;    @footnotestyle separate
  1117. ; or
  1118. ;    @footnotestyle end
  1119. ; The default is  separate
  1120.  
  1121. (defvar texinfo-footnote-style "separate" 
  1122.   "Footnote style, either separate or end.")
  1123.  
  1124. (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle)
  1125. (defun texinfo-footnotestyle ()
  1126.   "Specify whether footnotes are at end of node or in separate nodes.
  1127. Argument is either end or separate."
  1128.   (setq texinfo-footnote-style (texinfo-parse-arg-discard)))
  1129.  
  1130. (defvar texinfo-footnote-number)
  1131.  
  1132. (put 'footnote 'texinfo-format 'texinfo-format-footnote)
  1133. (defun texinfo-format-footnote ()
  1134.   "Format a footnote in either end of node or separate node style.
  1135. The   texinfo-footnote-style  variable controls which style is used."
  1136.   (setq texinfo-footnote-number (1+ texinfo-footnote-number))
  1137.   (cond ((string= texinfo-footnote-style "end")
  1138.          (texinfo-format-end-node))
  1139.         ((string= texinfo-footnote-style "separate")
  1140.          (texinfo-format-separate-node))))
  1141.  
  1142. (defun texinfo-format-separate-node ()
  1143.   "Format footnote in Separate node style, with notes in own node.
  1144. The node is constructed automatically."
  1145.   (let* (start
  1146.          (arg (texinfo-parse-line-arg))
  1147.          (node-name-beginning
  1148.           (save-excursion
  1149.             (re-search-backward
  1150.              "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:")
  1151.             (match-end 0)))
  1152.          (node-name
  1153.           (save-excursion
  1154.             (buffer-substring
  1155.              (progn (goto-char node-name-beginning) ; skip over node command
  1156.                     (skip-chars-forward " \t")  ; and over spaces
  1157.                     (point))
  1158.              (if (search-forward
  1159.                   ","
  1160.                   (save-excursion (end-of-line) (point)) t) ; bound search
  1161.                  (1- (point))
  1162.                (end-of-line) (point))))))
  1163.     (texinfo-discard-command)  ; remove or insert whitespace, as needed
  1164.     (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
  1165.                    (point))
  1166.     (insert (format " (%d) (*Note %s-Footnotes::)"
  1167.                     texinfo-footnote-number node-name))
  1168.     (fill-paragraph nil)
  1169.     (save-excursion
  1170.     (if (re-search-forward "^@node" nil 'move)
  1171.         (forward-line -1))
  1172.  
  1173.     ;; two cases: for the first footnote, we must insert a node header;
  1174.     ;; for the second and subsequent footnotes, we need only insert 
  1175.     ;; the text of the  footnote.
  1176.  
  1177.     (if (save-excursion
  1178.          (re-search-backward
  1179.           (concat node-name "-Footnotes, Up: ")
  1180.           node-name-beginning
  1181.           t))
  1182.         (progn   ; already at least one footnote
  1183.           (setq start (point))
  1184.           (insert (format "\n(%d)  %s\n" texinfo-footnote-number arg))
  1185.           (fill-region start (point)))
  1186.       ;; else not yet a footnote
  1187.       (insert "\n\^_\nFile: "  texinfo-format-filename
  1188.               "  Node: " node-name "-Footnotes, Up: " node-name "\n")
  1189.       (setq start (point))
  1190.       (insert (format "\n(%d)  %s\n" texinfo-footnote-number arg))
  1191.       (fill-region start (point))))))
  1192.  
  1193. (defun texinfo-format-end-node ()
  1194.   "Format footnote in the End of node style, with notes at end of node."
  1195.   (let (start
  1196.         (arg (texinfo-parse-line-arg)))
  1197.     (texinfo-discard-command)  ; remove or insert whitespace, as needed
  1198.     (delete-region (save-excursion (skip-chars-backward " \t\n") (point))
  1199.                    (point))
  1200.     (insert (format " (%d) " texinfo-footnote-number))
  1201.     (fill-paragraph nil)
  1202.     (save-excursion
  1203.       (if (search-forward "\n--------- Footnotes ---------\n" nil t)
  1204.           (progn ; already have footnote, put new one before end of node
  1205.             (if (re-search-forward "^@node" nil 'move)
  1206.                 (forward-line -1))
  1207.             (setq start (point))
  1208.             (insert (format "\n(%d)  %s\n" texinfo-footnote-number arg))
  1209.             (fill-region start (point)))
  1210.         ;; else no prior footnote
  1211.         (if (re-search-forward "^@node" nil 'move)
  1212.             (forward-line -1))
  1213.         (insert "\n--------- Footnotes ---------\n")
  1214.         (setq start (point))
  1215.         (insert (format "\n(%d)  %s\n" texinfo-footnote-number arg))))))
  1216.  
  1217.  
  1218. ;;; @itemize, @enumerate, and similar commands
  1219.  
  1220. ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
  1221. ;; @enumerate pushes (enumerate 0 STARTPOS).
  1222. ;; @item dispatches to the texinfo-item prop of the first elt of the list.
  1223. ;; For itemize, this puts in and rescans the COMMANDS.
  1224. ;; For enumerate, this increments the number and puts it in.
  1225. ;; In either case, it puts a Backspace at the front of the line
  1226. ;; which marks it not to be indented later.
  1227. ;; All other lines get indented by 5 when the @end is reached.
  1228.  
  1229. (defvar texinfo-stack-depth 0
  1230.   "Count of number of unpopped texinfo-push-stack calls.
  1231. Used by @refill indenting command to avoid indenting within lists, etc.")
  1232.  
  1233. (defun texinfo-push-stack (check arg)
  1234.   (setq texinfo-stack-depth (1+ texinfo-stack-depth))
  1235.   (setq texinfo-stack
  1236.         (cons (list check arg texinfo-command-start)
  1237.               texinfo-stack)))
  1238.  
  1239. (defun texinfo-pop-stack (check)
  1240.   (setq texinfo-stack-depth (1- texinfo-stack-depth))
  1241.   (if (null texinfo-stack)
  1242.       (error "Unmatched @end %s" check))
  1243.   (if (not (eq (car (car texinfo-stack)) check))
  1244.       (error "@end %s matches @%s"
  1245.              check (car (car texinfo-stack))))
  1246.   (prog1 (cdr (car texinfo-stack))
  1247.          (setq texinfo-stack (cdr texinfo-stack))))
  1248.  
  1249. (put 'itemize 'texinfo-format 'texinfo-itemize)
  1250. (defun texinfo-itemize ()
  1251.   (texinfo-push-stack
  1252.    'itemize
  1253.    (progn (skip-chars-forward " \t")
  1254.           (if (eolp)
  1255.               "@bullet"
  1256.             (texinfo-parse-line-arg))))
  1257.   (texinfo-discard-line-with-args)
  1258.   (setq fill-column (- fill-column 5)))
  1259.  
  1260. (put 'itemize 'texinfo-end 'texinfo-end-itemize)
  1261. (defun texinfo-end-itemize ()
  1262.   (setq fill-column (+ fill-column 5))
  1263.   (texinfo-discard-command)
  1264.   (let ((stacktop
  1265.          (texinfo-pop-stack 'itemize)))
  1266.     (texinfo-do-itemize (nth 1 stacktop))))
  1267.  
  1268. (put 'enumerate 'texinfo-format 'texinfo-enumerate)
  1269. (defun texinfo-enumerate ()
  1270.   (texinfo-push-stack
  1271.    'enumerate 
  1272.    (progn (skip-chars-forward " \t")
  1273.           (if (eolp)
  1274.               1
  1275.             (read (current-buffer)))))
  1276.   (if (and (symbolp (car (cdr (car texinfo-stack))))
  1277.            (> 1 (length (symbol-name (car (cdr (car texinfo-stack)))))))
  1278.       (error
  1279.        "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." ))
  1280.   (texinfo-discard-line-with-args)
  1281.   (setq fill-column (- fill-column 5)))
  1282.  
  1283. (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
  1284. (defun texinfo-end-enumerate ()
  1285.   (setq fill-column (+ fill-column 5))
  1286.   (texinfo-discard-command)
  1287.   (let ((stacktop
  1288.          (texinfo-pop-stack 'enumerate)))
  1289.     (texinfo-do-itemize (nth 1 stacktop))))
  1290.  
  1291. ;; @alphaenumerate never became a standard part of Texinfo
  1292. (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate)
  1293. (defun texinfo-alphaenumerate ()
  1294.   (texinfo-push-stack 'alphaenumerate (1- ?a))
  1295.   (setq fill-column (- fill-column 5))
  1296.   (texinfo-discard-line))
  1297.  
  1298. (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate)
  1299. (defun texinfo-end-alphaenumerate ()
  1300.   (setq fill-column (+ fill-column 5))
  1301.   (texinfo-discard-command)
  1302.   (let ((stacktop
  1303.          (texinfo-pop-stack 'alphaenumerate)))
  1304.     (texinfo-do-itemize (nth 1 stacktop))))
  1305.  
  1306. ;; @capsenumerate never became a standard part of Texinfo
  1307. (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate)
  1308. (defun texinfo-capsenumerate ()
  1309.   (texinfo-push-stack 'capsenumerate (1- ?A))
  1310.   (setq fill-column (- fill-column 5))
  1311.   (texinfo-discard-line))
  1312.  
  1313. (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate)
  1314. (defun texinfo-end-capsenumerate ()
  1315.   (setq fill-column (+ fill-column 5))
  1316.   (texinfo-discard-command)
  1317.   (let ((stacktop
  1318.          (texinfo-pop-stack 'capsenumerate)))
  1319.     (texinfo-do-itemize (nth 1 stacktop))))
  1320.  
  1321. ;; At the @end, indent all the lines within the construct
  1322. ;; except those marked with backspace.  FROM says where
  1323. ;; construct started.
  1324. (defun texinfo-do-itemize (from)
  1325.   (save-excursion
  1326.    (while (progn (forward-line -1)
  1327.                  (>= (point) from))
  1328.      (if (= (following-char) ?\b)
  1329.          (save-excursion
  1330.            (delete-char 1)
  1331.            (end-of-line)
  1332.            (delete-char 6))
  1333.        (if (not (looking-at "[ \t]*$"))
  1334.            (save-excursion (insert "     ")))))))
  1335.  
  1336. (put 'item 'texinfo-format 'texinfo-item)
  1337. (put 'itemx 'texinfo-format 'texinfo-item)
  1338. (defun texinfo-item ()
  1339.   (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
  1340.  
  1341. (put 'itemize 'texinfo-item 'texinfo-itemize-item)
  1342. (defun texinfo-itemize-item ()
  1343.   ;; (texinfo-discard-line)   ; Did not handle text on same line as @item.
  1344.   (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point)))
  1345.   (if (looking-at "[ \t]*[^ \t\n]+")
  1346.       ;; Text on same line as @item command.
  1347.       (insert "\b   " (nth 1 (car texinfo-stack)) " \n")
  1348.     ;; Else text on next line.
  1349.     (insert "\b   " (nth 1 (car texinfo-stack)) " "))
  1350.   (forward-line -1))
  1351.  
  1352. (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
  1353. (defun texinfo-enumerate-item ()
  1354.   (texinfo-discard-line)
  1355.   (let (enumerating-symbol)
  1356.     (cond ((integerp (car (cdr (car texinfo-stack))))
  1357.            (setq enumerating-symbol (car (cdr (car texinfo-stack))))
  1358.            (insert ?\b (format "%3d. " enumerating-symbol) ?\n)
  1359.            (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol)))
  1360.           ((symbolp (car (cdr (car texinfo-stack))))
  1361.            (setq enumerating-symbol
  1362.                  (symbol-name (car (cdr (car texinfo-stack)))))
  1363.            (if (or (equal ?\[ (string-to-char enumerating-symbol))
  1364.                    (equal ?\{ (string-to-char enumerating-symbol)))
  1365.                (error
  1366.                 "Too many items in enumerated list; alphabet ends at Z."))
  1367.            (insert ?\b (format "%3s. " enumerating-symbol) ?\n)
  1368.            (setcar (cdr (car texinfo-stack))
  1369.                    (make-symbol
  1370.                     (char-to-string
  1371.                      (1+ 
  1372.                       (string-to-char enumerating-symbol))))))
  1373.           (t
  1374.           (error
  1375.            "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." )))
  1376.     (forward-line -1)))
  1377.  
  1378. (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item)
  1379. (defun texinfo-alphaenumerate-item ()
  1380.   (texinfo-discard-line)
  1381.   (let ((next (1+ (car (cdr (car texinfo-stack))))))
  1382.     (if (> next ?z)
  1383.         (error "More than 26 items in @alphaenumerate; get a bigger alphabet."))
  1384.     (setcar (cdr (car texinfo-stack)) next)
  1385.     (insert "\b  " next ". \n"))
  1386.   (forward-line -1))
  1387.  
  1388. (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item)
  1389. (defun texinfo-capsenumerate-item ()
  1390.   (texinfo-discard-line)
  1391.   (let ((next (1+ (car (cdr (car texinfo-stack))))))
  1392.     (if (> next ?Z)
  1393.         (error "More than 26 items in @capsenumerate; get a bigger alphabet."))
  1394.     (setcar (cdr (car texinfo-stack)) next)
  1395.     (insert "\b  " next ". \n"))
  1396.   (forward-line -1))
  1397.  
  1398.  
  1399. ;;; @table
  1400.  
  1401. ; The `@table' command produces two-column tables.
  1402.  
  1403. (put 'table 'texinfo-format 'texinfo-table)
  1404. (defun texinfo-table ()
  1405.   (texinfo-push-stack 
  1406.    'table 
  1407.    (progn (skip-chars-forward " \t")
  1408.           (if (eolp)
  1409.               "@asis"
  1410.             (texinfo-parse-line-arg))))
  1411.   (texinfo-discard-line-with-args)
  1412.   (setq fill-column (- fill-column 5)))
  1413.  
  1414. (put 'table 'texinfo-item 'texinfo-table-item)
  1415. (defun texinfo-table-item ()
  1416.   (let ((arg (texinfo-parse-arg-discard))
  1417.         (itemfont (car (cdr (car texinfo-stack)))))
  1418.     (insert ?\b itemfont ?\{ arg "}\n     \n"))
  1419.   (forward-line -2))
  1420.  
  1421. (put 'table 'texinfo-end 'texinfo-end-table)
  1422. (defun texinfo-end-table ()
  1423.   (setq fill-column (+ fill-column 5))
  1424.   (texinfo-discard-command)
  1425.   (let ((stacktop
  1426.          (texinfo-pop-stack 'table)))
  1427.     (texinfo-do-itemize (nth 1 stacktop))))
  1428.  
  1429. ;; @description appears to be an undocumented variant on @table that
  1430. ;; does not require an arg.  It fails in texinfo.tex 2.58 and is not
  1431. ;; part of makeinfo.c   The command appears to be a relic of the past.
  1432. (put 'description 'texinfo-end 'texinfo-end-table)
  1433. (put 'description 'texinfo-format 'texinfo-description)
  1434. (defun texinfo-description ()
  1435.   (texinfo-push-stack 'table "@asis")
  1436.   (setq fill-column (- fill-column 5))
  1437.   (texinfo-discard-line))
  1438.  
  1439.  
  1440. ;;; @ftable, @vtable
  1441.  
  1442. ; The `@ftable' and `@vtable' commands are like the `@table' command
  1443. ; but they also insert each entry in the first column of the table
  1444. ; into the function or variable index.
  1445.  
  1446. ;; Handle the @ftable and @vtable commands:
  1447.  
  1448. (put 'ftable 'texinfo-format 'texinfo-ftable)
  1449. (put 'vtable 'texinfo-format 'texinfo-vtable)
  1450.  
  1451. (defun texinfo-ftable () (texinfo-indextable 'ftable))
  1452. (defun texinfo-vtable () (texinfo-indextable 'vtable))
  1453.  
  1454. (defun texinfo-indextable (table-type)
  1455.   (texinfo-push-stack table-type (texinfo-parse-arg-discard))
  1456.   (setq fill-column (- fill-column 5)))
  1457.  
  1458. ;; Handle the @item commands within ftable and vtable:
  1459.  
  1460. (put 'ftable 'texinfo-item 'texinfo-ftable-item)
  1461. (put 'vtable 'texinfo-item 'texinfo-vtable-item)
  1462.  
  1463. (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex))
  1464. (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex))
  1465.  
  1466. (defun texinfo-indextable-item (index-type)
  1467.   (let ((item (texinfo-parse-arg-discard))
  1468.         (itemfont (car (cdr (car texinfo-stack))))
  1469.         (indexvar index-type))
  1470.     (insert ?\b itemfont ?\{ item "}\n     \n")
  1471.     (set indexvar
  1472.          (cons
  1473.           (list item texinfo-last-node)
  1474.           (symbol-value indexvar)))
  1475.     (forward-line -2)))
  1476.  
  1477. ;; Handle @end ftable, @end vtable
  1478.  
  1479. (put 'ftable 'texinfo-end 'texinfo-end-ftable)
  1480. (put 'vtable 'texinfo-end 'texinfo-end-vtable)
  1481.  
  1482. (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable))
  1483. (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable))
  1484.  
  1485. (defun texinfo-end-indextable (table-type)
  1486.   (setq fill-column (+ fill-column 5))
  1487.   (texinfo-discard-command)
  1488.   (let ((stacktop
  1489.          (texinfo-pop-stack table-type)))
  1490.     (texinfo-do-itemize (nth 1 stacktop))))
  1491.  
  1492.  
  1493. ;;; @ifinfo,  @iftex, @tex
  1494.  
  1495. (put 'ifinfo 'texinfo-format 'texinfo-discard-line)
  1496. (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
  1497.  
  1498. (put 'iftex 'texinfo-format 'texinfo-format-iftex)
  1499. (defun texinfo-format-iftex ()
  1500.   (delete-region texinfo-command-start
  1501.                  (progn (re-search-forward "@end iftex[ \t]*\n")
  1502.                         (point))))
  1503.  
  1504. (put 'tex 'texinfo-format 'texinfo-format-tex)
  1505. (defun texinfo-format-tex ()
  1506.   (delete-region texinfo-command-start
  1507.                  (progn (re-search-forward "@end tex[ \t]*\n")
  1508.                         (point))))
  1509.  
  1510.  
  1511. ;;; @titlepage
  1512.  
  1513. (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
  1514. (defun texinfo-format-titlepage ()
  1515.   (delete-region texinfo-command-start
  1516.                  (progn (re-search-forward "@end titlepage[ \t]*\n")
  1517.                         (point))))
  1518.  
  1519. (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
  1520.  
  1521. ; @titlespec         an alternative titling command; ignored by Info
  1522.  
  1523. (put 'titlespec 'texinfo-format 'texinfo-format-titlespec)
  1524. (defun texinfo-format-titlespec ()
  1525.   (delete-region texinfo-command-start
  1526.                  (progn (re-search-forward "@end titlespec[ \t]*\n")
  1527.                         (point))))
  1528.  
  1529. (put 'endtitlespec 'texinfo-format 'texinfo-discard-line)
  1530.  
  1531.  
  1532. ;;; @today
  1533.  
  1534. (put 'today 'texinfo-format 'texinfo-format-today)
  1535.  
  1536. ; Produces Day Month Year style of output.  eg `1 Jan 1900'
  1537. ; The `@today{}' command requires a pair of braces, like `@dots{}'.
  1538. (defun texinfo-format-today ()
  1539.   (texinfo-parse-arg-discard)
  1540.   (insert (format "%s %s %s"
  1541.           (substring (current-time-string) 8 10)
  1542.           (substring (current-time-string) 4 7)
  1543.           (substring (current-time-string) -4))))
  1544.  
  1545.  
  1546. ;;; @ignore
  1547.  
  1548. (put 'ignore 'texinfo-format 'texinfo-format-ignore)
  1549. (defun texinfo-format-ignore ()
  1550.   (delete-region texinfo-command-start
  1551.                  (progn (re-search-forward "@end ignore[ \t]*\n")
  1552.                         (point))))
  1553.  
  1554. (put 'endignore 'texinfo-format 'texinfo-discard-line)
  1555.  
  1556.  
  1557. ;;; Define the Info enclosure command: @definfoenclose
  1558.  
  1559. ; A `@definfoenclose' command may be used to define a highlighting
  1560. ; command for Info, but not for TeX.  A command defined using
  1561. ; `@definfoenclose' marks text by enclosing it in strings that precede
  1562. ; and follow the text.
  1563. ; Presumably, if you define a command with `@definfoenclose` for Info,
  1564. ; you will also define the same command in the TeX definitions file,
  1565. ; `texinfo.tex' in a manner appropriate for typesetting.
  1566. ; Write a `@definfoenclose' command on a line and follow it with three
  1567. ; arguments separated by commas (commas are used as separators in an
  1568. ; `@node' line in the same way).  The first argument to
  1569. ; `@definfoenclose' is the @-command name \(without the `@'\); the
  1570. ; second argument is the Info start delimiter string; and the third
  1571. ; argument is the Info end delimiter string.  The latter two arguments
  1572. ; enclose the highlighted text in the Info file.  A delimiter string
  1573. ; may contain spaces.  Neither the start nor end delimiter is
  1574. ; required.  However, if you do not provide a start delimiter, you
  1575. ; must follow the command name with two commas in a row; otherwise,
  1576. ; the Info formatting commands will misinterpret the end delimiter
  1577. ; string as a start delimiter string.
  1578. ; An enclosure command defined this way takes one argument in braces.
  1579. ;
  1580. ; For example, you can write:
  1581. ;
  1582. ;     @ifinfo
  1583. ;     @definfoenclose phoo, //, \\
  1584. ;     @end ifinfo
  1585. ;
  1586. ; near the beginning of a Texinfo file at the beginning of the lines
  1587. ; to define `@phoo' as an Info formatting command that inserts `//'
  1588. ; before and `\\' after the argument to `@phoo'.  You can then write
  1589. ; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info.
  1590. ;
  1591. ; Also, for TeX formatting, you could write 
  1592. ;
  1593. ;     @iftex
  1594. ;     @global@let@phoo=@i
  1595. ;     @end iftex
  1596. ;
  1597. ; to define `@phoo' as a command that causes TeX to typeset
  1598. ; the argument to `@phoo' in italics.
  1599. ;
  1600. ; Note that each definition applies to its own formatter: one for TeX,
  1601. ; the other for texinfo-format-buffer or texinfo-format-region.
  1602. ;
  1603. ; Here is another example: write
  1604. ;
  1605. ;     @definfoenclose headword, , :
  1606. ;
  1607. ; near the beginning of the file, to define `@headword' as an Info
  1608. ; formatting command that inserts nothing before and a colon after the
  1609. ; argument to `@headword'.
  1610.  
  1611. (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure)
  1612. (defun texinfo-define-info-enclosure ()
  1613.   (let* ((args (texinfo-format-parse-line-args))
  1614.          (command-name (nth 0 args))
  1615.          (beginning-delimiter (or (nth 1 args) ""))
  1616.          (end-delimiter (or (nth 2 args) "")))
  1617.     (texinfo-discard-command)
  1618.     (setq texinfo-enclosure-list
  1619.         (cons
  1620.          (list command-name
  1621.                (list
  1622.                 beginning-delimiter
  1623.                 end-delimiter))
  1624.          texinfo-enclosure-list))))
  1625.  
  1626.  
  1627. ;;; @var, @code and the like
  1628.  
  1629. (put 'var 'texinfo-format 'texinfo-format-var)
  1630. ;  @sc  a small caps font for TeX; formatted as `var' in Info
  1631. (put 'sc 'texinfo-format 'texinfo-format-var)
  1632. (defun texinfo-format-var ()
  1633.   (insert (upcase (texinfo-parse-arg-discard)))
  1634.   (goto-char texinfo-command-start))
  1635.  
  1636. ; various noops
  1637.  
  1638. (put 'b 'texinfo-format 'texinfo-format-noop)
  1639. (put 'i 'texinfo-format 'texinfo-format-noop)
  1640. (put 'r 'texinfo-format 'texinfo-format-noop)
  1641. (put 't 'texinfo-format 'texinfo-format-noop)
  1642. (put 'w 'texinfo-format 'texinfo-format-noop)
  1643. (put 'asis 'texinfo-format 'texinfo-format-noop)
  1644. (put 'dmn 'texinfo-format 'texinfo-format-noop)
  1645. (put 'key 'texinfo-format 'texinfo-format-noop)
  1646. (put 'math 'texinfo-format 'texinfo-format-noop)
  1647. (put 'titlefont 'texinfo-format 'texinfo-format-noop)
  1648. (defun texinfo-format-noop ()
  1649.   (insert (texinfo-parse-arg-discard))
  1650.   (goto-char texinfo-command-start))
  1651.  
  1652. (put 'cite 'texinfo-format 'texinfo-format-code)
  1653. (put 'code 'texinfo-format 'texinfo-format-code)
  1654. (put 'file 'texinfo-format 'texinfo-format-code)
  1655. (put 'kbd 'texinfo-format 'texinfo-format-code)
  1656. (put 'samp 'texinfo-format 'texinfo-format-code)
  1657. (defun texinfo-format-code ()
  1658.   (insert "`" (texinfo-parse-arg-discard) "'")
  1659.   (goto-char texinfo-command-start))
  1660.  
  1661. (put 'emph 'texinfo-format 'texinfo-format-emph)
  1662. (put 'strong 'texinfo-format 'texinfo-format-emph)
  1663. (defun texinfo-format-emph ()
  1664.   (insert "*" (texinfo-parse-arg-discard) "*")
  1665.   (goto-char texinfo-command-start))
  1666.  
  1667. (put 'dfn 'texinfo-format 'texinfo-format-defn)
  1668. (put 'defn 'texinfo-format 'texinfo-format-defn)
  1669. (defun texinfo-format-defn ()
  1670.   (insert "\"" (texinfo-parse-arg-discard) "\"")
  1671.   (goto-char texinfo-command-start))
  1672.  
  1673. (put 'bullet 'texinfo-format 'texinfo-format-bullet)
  1674. (defun texinfo-format-bullet ()
  1675.   "Insert an asterisk.
  1676. If used within a line, follow `@bullet' with braces."
  1677.   (texinfo-optional-braces-discard)
  1678.   (insert "*"))
  1679.  
  1680.  
  1681. ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample
  1682.  
  1683. (put 'display 'texinfo-format 'texinfo-format-example)
  1684. (put 'example 'texinfo-format 'texinfo-format-example)
  1685. (put 'lisp 'texinfo-format 'texinfo-format-example)
  1686. (put 'quotation 'texinfo-format 'texinfo-format-example)
  1687. (put 'smallexample 'texinfo-format 'texinfo-format-example)
  1688. (put 'smalllisp 'texinfo-format 'texinfo-format-example)
  1689. (defun texinfo-format-example ()
  1690.   (texinfo-push-stack 'example nil)
  1691.   (setq fill-column (- fill-column 5))
  1692.   (texinfo-discard-line))
  1693.  
  1694. (put 'example 'texinfo-end 'texinfo-end-example)
  1695. (put 'display 'texinfo-end 'texinfo-end-example)
  1696. (put 'lisp 'texinfo-end 'texinfo-end-example)
  1697. (put 'quotation 'texinfo-end 'texinfo-end-example)
  1698. (put 'smallexample 'texinfo-end 'texinfo-end-example)
  1699. (put 'smalllisp 'texinfo-end 'texinfo-end-example)
  1700. (defun texinfo-end-example ()
  1701.   (setq fill-column (+ fill-column 5))
  1702.   (texinfo-discard-command)
  1703.   (let ((stacktop
  1704.          (texinfo-pop-stack 'example)))
  1705.     (texinfo-do-itemize (nth 1 stacktop))))
  1706.  
  1707. (put 'exdent 'texinfo-format 'texinfo-format-exdent)
  1708. (defun texinfo-format-exdent ()
  1709.   (texinfo-discard-command)
  1710.   (delete-region (point)
  1711.                  (progn
  1712.                   (skip-chars-forward " ")
  1713.                   (point)))
  1714.   (insert ?\b)
  1715.   ;; Cancel out the deletion that texinfo-do-itemize
  1716.   ;; is going to do at the end of this line.
  1717.   (save-excursion
  1718.     (end-of-line)
  1719.     (insert "\n     ")))
  1720.  
  1721.  
  1722. ;;; @cartouche 
  1723.  
  1724. ; The @cartouche command is a noop in Info; in a printed manual,
  1725. ; it makes a box with rounded corners.
  1726.  
  1727. (put 'cartouche 'texinfo-format 'texinfo-discard-line)
  1728. (put 'cartouche 'texinfo-end 'texinfo-discard-command)
  1729.  
  1730.  
  1731. ;;; @flushleft and @format
  1732.  
  1733. ; The @flushleft command left justifies every line but leaves the
  1734. ; right end ragged.  As far as Info is concerned, @flushleft is a
  1735. ; `do-nothing' command
  1736.  
  1737. ; The @format command is similar to @example except that it does not
  1738. ; indent; this means that in Info, @format is similar to @flushleft.
  1739.  
  1740. (put 'format 'texinfo-format 'texinfo-format-flushleft)
  1741. (put 'flushleft 'texinfo-format 'texinfo-format-flushleft)
  1742. (defun texinfo-format-flushleft ()
  1743.   (texinfo-discard-line))
  1744.  
  1745. (put 'format 'texinfo-end 'texinfo-end-flushleft)
  1746. (put 'flushleft 'texinfo-end 'texinfo-end-flushleft)
  1747. (defun texinfo-end-flushleft ()
  1748.   (texinfo-discard-command))
  1749.  
  1750.  
  1751. ;;; @flushright
  1752.  
  1753. ; The @flushright command right justifies every line but leaves the
  1754. ; left end ragged.  Spaces and tabs at the right ends of lines are
  1755. ; removed so that visible text lines up on the right side.
  1756.  
  1757. (put 'flushright 'texinfo-format 'texinfo-format-flushright)
  1758. (defun texinfo-format-flushright ()
  1759.   (texinfo-push-stack 'flushright nil)
  1760.   (texinfo-discard-line))
  1761.  
  1762. (put 'flushright 'texinfo-end 'texinfo-end-flushright)
  1763. (defun texinfo-end-flushright ()
  1764.   (texinfo-discard-command)
  1765.  
  1766.   (let ((stacktop
  1767.          (texinfo-pop-stack 'flushright)))
  1768.  
  1769.     (texinfo-do-flushright (nth 1 stacktop))))
  1770.  
  1771. (defun texinfo-do-flushright (from)
  1772.   (save-excursion
  1773.    (while (progn (forward-line -1)
  1774.                  (>= (point) from))
  1775.  
  1776.      (beginning-of-line)
  1777.      (insert
  1778.       (make-string
  1779.        (- fill-column
  1780.           (save-excursion
  1781.             (end-of-line) 
  1782.             (skip-chars-backward " \t")
  1783.             (delete-region (point) (progn (end-of-line) (point)))
  1784.             (current-column)))  
  1785.        ? )))))
  1786.  
  1787.  
  1788. ;;; @ctrl, @TeX, @copyright, @minus, @dots
  1789.  
  1790. (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
  1791. (defun texinfo-format-ctrl ()
  1792.   (let ((str (texinfo-parse-arg-discard)))
  1793.     (insert (logand 31 (aref str 0)))))
  1794.  
  1795. (put 'TeX 'texinfo-format 'texinfo-format-TeX)
  1796. (defun texinfo-format-TeX ()
  1797.   (texinfo-parse-arg-discard)
  1798.   (insert "TeX"))
  1799.  
  1800. (put 'copyright 'texinfo-format 'texinfo-format-copyright)
  1801. (defun texinfo-format-copyright ()
  1802.   (texinfo-parse-arg-discard)
  1803.   (insert "(C)"))
  1804.  
  1805. (put 'minus 'texinfo-format 'texinfo-format-minus)
  1806. (defun texinfo-format-minus ()
  1807.   "Insert a minus sign.
  1808. If used within a line, follow `@minus' with braces."
  1809.   (texinfo-optional-braces-discard)
  1810.   (insert "-"))
  1811.  
  1812. (put 'dots 'texinfo-format 'texinfo-format-dots)
  1813. (defun texinfo-format-dots ()
  1814.   (texinfo-parse-arg-discard)
  1815.   (insert "..."))
  1816.  
  1817.  
  1818. ;;; Refilling and indenting:  @refill, @paragraphindent, @noindent
  1819.  
  1820. ;;; Indent only those paragraphs that are refilled as a result of an
  1821. ;;; @refill command.  
  1822.  
  1823. ;    * If the value is `asis', do not change the existing indentation at
  1824. ;      the starts of paragraphs.
  1825.  
  1826. ;    * If the value zero, delete any existing indentation.
  1827.  
  1828. ;    * If the value is greater than zero, indent each paragraph by that
  1829. ;      number of spaces.
  1830.  
  1831. ;;; But do not refill paragraphs with an @refill command that are
  1832. ;;; preceded by @noindent or are part of a table, list, or deffn.
  1833.  
  1834. (defvar texinfo-paragraph-indent "asis"
  1835.   "Number of spaces for @refill to indent a paragraph; else to leave as is.")
  1836.  
  1837. (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent)
  1838.  
  1839. (defun texinfo-paragraphindent ()
  1840.   "Specify the number of spaces for @refill to indent a paragraph.
  1841. Default is to leave the number of spaces as is."
  1842.   (let ((arg  (texinfo-parse-arg-discard)))
  1843.     (if (string= "asis" arg)
  1844.         (setq texinfo-paragraph-indent "asis")
  1845.       (setq texinfo-paragraph-indent (string-to-int arg)))))
  1846.  
  1847. (put 'refill 'texinfo-format 'texinfo-format-refill)
  1848. (defun texinfo-format-refill ()
  1849.   "Refill paragraph. Also, indent first line as set by @paragraphindent.
  1850. Default is to leave paragraph indentation as is."
  1851.   (texinfo-discard-command)
  1852.   (forward-paragraph -1)     
  1853.   (if (looking-at "[ \t\n]*$") (forward-line 1))
  1854.   ;; Do not indent if an entry in a list, table, or deffn,
  1855.   ;; or if paragraph is preceded by @noindent.
  1856.   ;; Otherwise, indent
  1857.   (cond 
  1858.    ;; delete a @noindent line and do not indent paragraph
  1859.    ((save-excursion (forward-line -1)
  1860.                     (looking-at "^@noindent")) 
  1861.     (forward-line -1)
  1862.     (delete-region (point) (progn (forward-line 1) (point))))
  1863.    ;; do nothing if "asis"
  1864.    ((equal texinfo-paragraph-indent "asis"))
  1865.    ;; do no indenting in list, etc.
  1866.    ((> texinfo-stack-depth 0))   
  1867.    ;; otherwise delete existing whitespace and indent
  1868.    (t 
  1869.     (delete-region (point) (progn (skip-chars-forward " \t") (point)))
  1870.     (insert (make-string texinfo-paragraph-indent ? ))))
  1871.   (forward-paragraph 1) 
  1872.   (forward-line -1)
  1873.   (end-of-line)
  1874.   ;; Do not fill a section title line with asterisks, hyphens, etc. that
  1875.   ;; are used to underline it.  This could occur if the line following
  1876.   ;; the underlining is not an index entry and has text within it.
  1877.   (let* ((previous-paragraph-separate paragraph-separate)
  1878.          (paragraph-separate (concat paragraph-separate "\\|^[=*---.]+"))
  1879.          (previous-paragraph-start paragraph-start)
  1880.          (paragraph-start (concat paragraph-start "\\|^[=*---.]+")))
  1881.     (unwind-protect
  1882.         (fill-paragraph nil)
  1883.       (setq paragraph-separate previous-paragraph-separate)
  1884.       (setq paragraph-start previous-paragraph-start))))
  1885.  
  1886. (put 'noindent 'texinfo-format 'texinfo-noindent)
  1887. (defun texinfo-noindent ()  
  1888.   (save-excursion 
  1889.     (forward-paragraph 1)
  1890.     (if (search-backward "@refill"
  1891.                             (save-excursion (forward-line -1) (point)) t)
  1892.         () ; leave @noindent command so @refill command knows not to indent
  1893.       ;; else
  1894.       (texinfo-discard-line))))
  1895.  
  1896.  
  1897. ;;; Index generation
  1898.  
  1899. (put 'vindex 'texinfo-format 'texinfo-format-vindex)
  1900. (defun texinfo-format-vindex ()
  1901.   (texinfo-index 'texinfo-vindex))
  1902.  
  1903. (put 'cindex 'texinfo-format 'texinfo-format-cindex)
  1904. (defun texinfo-format-cindex ()
  1905.   (texinfo-index 'texinfo-cindex))
  1906.  
  1907. (put 'findex 'texinfo-format 'texinfo-format-findex)
  1908. (defun texinfo-format-findex ()
  1909.   (texinfo-index 'texinfo-findex))
  1910.  
  1911. (put 'pindex 'texinfo-format 'texinfo-format-pindex)
  1912. (defun texinfo-format-pindex ()
  1913.   (texinfo-index 'texinfo-pindex))
  1914.  
  1915. (put 'tindex 'texinfo-format 'texinfo-format-tindex)
  1916. (defun texinfo-format-tindex ()
  1917.   (texinfo-index 'texinfo-tindex))
  1918.  
  1919. (put 'kindex 'texinfo-format 'texinfo-format-kindex)
  1920. (defun texinfo-format-kindex ()
  1921.   (texinfo-index 'texinfo-kindex))
  1922.  
  1923. (defun texinfo-index (indexvar)
  1924.   (let ((arg (texinfo-parse-expanded-arg)))
  1925.     (texinfo-discard-command)
  1926.     (set indexvar
  1927.          (cons (list arg
  1928.                      texinfo-last-node
  1929.                      ;; Region formatting may not provide last node position.
  1930.                      (if texinfo-last-node-pos
  1931.                          (1+ (count-lines texinfo-last-node-pos (point)))
  1932.                        1))
  1933.                (symbol-value indexvar)))))
  1934.  
  1935. (defconst texinfo-indexvar-alist
  1936.   '(("cp" . texinfo-cindex)
  1937.     ("fn" . texinfo-findex)
  1938.     ("vr" . texinfo-vindex)
  1939.     ("tp" . texinfo-tindex)
  1940.     ("pg" . texinfo-pindex)
  1941.     ("ky" . texinfo-kindex)))
  1942.  
  1943.  
  1944. ;;; @defindex   @defcodeindex
  1945. (put 'defindex 'texinfo-format 'texinfo-format-defindex)
  1946. (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex)
  1947.  
  1948. (defun texinfo-format-defindex ()
  1949.   (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa'
  1950.          (indexing-command (intern (concat index-name "index")))
  1951.          (index-formatting-command      ; eg: `texinfo-format-aaindex'
  1952.           (intern (concat "texinfo-format-" index-name "index")))
  1953.          (index-alist-name              ; eg: `texinfo-aaindex'
  1954.           (intern (concat "texinfo-" index-name "index"))))
  1955.  
  1956.     (set index-alist-name nil)
  1957.  
  1958.     (put indexing-command               ; eg, aaindex
  1959.          'texinfo-format
  1960.          index-formatting-command)      ; eg, texinfo-format-aaindex
  1961.  
  1962.     ;; eg: "aa" . texinfo-aaindex
  1963.     (or (assoc index-name texinfo-indexvar-alist)
  1964.         (setq texinfo-indexvar-alist
  1965.               (cons
  1966.                (cons index-name
  1967.                      index-alist-name)
  1968.                texinfo-indexvar-alist)))
  1969.  
  1970.     (fset index-formatting-command
  1971.           (list 'lambda 'nil
  1972.                 (list 'texinfo-index 
  1973.                       (list 'quote index-alist-name))))))
  1974.  
  1975.  
  1976. ;;; @synindex   @syncodeindex
  1977.  
  1978. (put 'synindex 'texinfo-format 'texinfo-format-synindex)
  1979. (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex)
  1980.  
  1981. (defun texinfo-format-synindex ()
  1982.   (let* ((args (texinfo-parse-arg-discard))
  1983.          (second (cdr (read-from-string args)))
  1984.          (joiner (symbol-name (car (read-from-string args))))
  1985.          (joined (symbol-name (car (read-from-string args second)))))
  1986.  
  1987.     (if (assoc joiner texinfo-short-index-cmds-alist)
  1988.         (put
  1989.           (cdr (assoc joiner texinfo-short-index-cmds-alist))
  1990.          'texinfo-format
  1991.          (or (cdr (assoc joined texinfo-short-index-format-cmds-alist))
  1992.              (intern (concat "texinfo-format-" joined "index"))))
  1993.       (put
  1994.        (intern (concat joiner "index"))
  1995.        'texinfo-format
  1996.        (or (cdr(assoc joined texinfo-short-index-format-cmds-alist))
  1997.            (intern (concat "texinfo-format-" joined "index")))))))
  1998.  
  1999. (defconst texinfo-short-index-cmds-alist
  2000.   '(("cp" . cindex)
  2001.     ("fn" . findex)
  2002.     ("vr" . vindex)
  2003.     ("tp" . tindex)
  2004.     ("pg" . pindex)
  2005.     ("ky" . kindex)))
  2006.  
  2007. (defconst texinfo-short-index-format-cmds-alist
  2008.   '(("cp" . texinfo-format-cindex)
  2009.     ("fn" . texinfo-format-findex)
  2010.     ("vr" . texinfo-format-vindex)
  2011.     ("tp" . texinfo-format-tindex)
  2012.     ("pg" . texinfo-format-pindex)
  2013.     ("ky" . texinfo-format-kindex)))
  2014.  
  2015.  
  2016. ;;; Sort and index (for VMS)
  2017.  
  2018. ;; Sort an index which is in the current buffer between START and END.
  2019. ;; Used on VMS, where the `sort' utility is not available.
  2020. (defun texinfo-sort-region (start end)
  2021.   (require 'sort)
  2022.   (save-restriction
  2023.     (narrow-to-region start end)
  2024.     (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun)))
  2025.  
  2026. ;; Subroutine for sorting an index.
  2027. ;; At start of a line, return a string to sort the line under.
  2028. (defun texinfo-sort-startkeyfun ()
  2029.   (let ((line
  2030.          (buffer-substring (point) (save-excursion (end-of-line) (point)))))
  2031.     ;; Canonicalize whitespace and eliminate funny chars.
  2032.     (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line)
  2033.       (setq line (concat (substring line 0 (match-beginning 0))
  2034.                          " "
  2035.                          (substring line (match-end 0) (length line)))))
  2036.     line))
  2037.  
  2038.  
  2039. ;;; @printindex
  2040.  
  2041. (put 'printindex 'texinfo-format 'texinfo-format-printindex)
  2042.  
  2043. (defun texinfo-format-printindex ()
  2044.   (let ((indexelts (symbol-value
  2045.                     (cdr (assoc (texinfo-parse-arg-discard)
  2046.                                 texinfo-indexvar-alist))))
  2047.         opoint)
  2048.     (insert "\n* Menu:\n\n")
  2049.     (setq opoint (point))
  2050.     (texinfo-print-index nil indexelts)
  2051.  
  2052.     (if (eq system-type 'vax-vms)
  2053.         (texinfo-sort-region opoint (point))
  2054.       (shell-command-on-region opoint (point) "sort -fd" 1))))
  2055.  
  2056. (defun texinfo-print-index (file indexelts)
  2057.   (while indexelts
  2058.     (if (stringp (car (car indexelts)))
  2059.         (progn
  2060.           (insert "* " (car (car indexelts)) ": " )
  2061.           (indent-to 32)
  2062.           (insert
  2063.            (if file (concat "(" file ")") "")
  2064.            (nth 1 (car indexelts)) ".")
  2065.           (indent-to 54)
  2066.           (insert
  2067.            (if (nth 2 (car indexelts))
  2068.                (format "  %d." (nth 2 (car indexelts)))
  2069.              "")
  2070.            "\n"))
  2071.       ;; index entries from @include'd file
  2072.       (texinfo-print-index (nth 1 (car indexelts))
  2073.                            (nth 2 (car indexelts))))
  2074.     (setq indexelts (cdr indexelts))))
  2075.  
  2076.  
  2077. ;;; Glyphs: @equiv, @error, etc
  2078.  
  2079. ;; @equiv           to show that two expressions are equivalent
  2080. ;; @error           to show an error message
  2081. ;; @expansion       to show what a macro expands to
  2082. ;; @point           to show the location of point in an example
  2083. ;; @print           to show what an evaluated expression prints
  2084. ;; @result          to indicate the value returned by an expression
  2085.  
  2086. (put 'equiv 'texinfo-format 'texinfo-format-equiv)
  2087. (defun texinfo-format-equiv ()
  2088.   (texinfo-parse-arg-discard)
  2089.   (insert "=="))
  2090.  
  2091. (put 'error 'texinfo-format 'texinfo-format-error)
  2092. (defun texinfo-format-error ()
  2093.   (texinfo-parse-arg-discard)
  2094.   (insert "error-->"))
  2095.  
  2096. (put 'expansion 'texinfo-format 'texinfo-format-expansion)
  2097. (defun texinfo-format-expansion ()
  2098.   (texinfo-parse-arg-discard)
  2099.   (insert "==>"))
  2100.  
  2101. (put 'point 'texinfo-format 'texinfo-format-point)
  2102. (defun texinfo-format-point ()
  2103.   (texinfo-parse-arg-discard)
  2104.   (insert "-!-"))
  2105.  
  2106. (put 'print 'texinfo-format 'texinfo-format-print)
  2107. (defun texinfo-format-print ()
  2108.   (texinfo-parse-arg-discard)
  2109.   (insert "-|"))
  2110.  
  2111. (put 'result 'texinfo-format 'texinfo-format-result)
  2112. (defun texinfo-format-result ()
  2113.   (texinfo-parse-arg-discard)
  2114.   (insert "=>"))
  2115.  
  2116.  
  2117. ;;; Definition formatting: @deffn, @defun, etc
  2118.  
  2119. ;; What definition formatting produces:
  2120. ;;
  2121. ;; @deffn category name args...
  2122. ;;     In Info, `Category: name ARGS'
  2123. ;;     In index: name:  node. line#.
  2124. ;;
  2125. ;; @defvr category name 
  2126. ;;     In Info, `Category: name'
  2127. ;;     In index: name:  node. line#.
  2128. ;;
  2129. ;; @deftp category name attributes...
  2130. ;; `category name attributes...'       Note: @deftp args in lower case.
  2131. ;;     In index: name:  node. line#.
  2132. ;;
  2133. ;; Specialized function-like or variable-like entity:
  2134. ;;
  2135. ;; @defun, @defmac, @defspec, @defvar, @defopt
  2136. ;;
  2137. ;; @defun name args           In Info, `Function: name ARGS'
  2138. ;; @defmac name args          In Info, `Macro: name ARGS'
  2139. ;; @defvar name               In Info, `Variable: name'
  2140. ;; etc.
  2141. ;;     In index: name:  node. line#.
  2142. ;;
  2143. ;; Generalized typed-function-like or typed-variable-like entity:
  2144. ;; @deftypefn category data-type name args...
  2145. ;;     In Info, `Category:  data-type name args...'
  2146. ;; @deftypevr category data-type name 
  2147. ;;     In Info, `Category:  data-type name'
  2148. ;;     In index: name:  node. line#.
  2149. ;;
  2150. ;; Specialized typed-function-like or typed-variable-like entity:
  2151. ;; @deftypefun data-type name args...
  2152. ;;     In Info, `Function:  data-type name ARGS'
  2153. ;;     In index: name:  node. line#.   
  2154. ;;
  2155. ;; @deftypevar data-type name 
  2156. ;;     In Info, `Variable:  data-type name'
  2157. ;;     In index: name:  node. line#.   but include args after name!?
  2158. ;;
  2159. ;; Generalized object oriented entity: 
  2160. ;; @defop category class name args...
  2161. ;;     In Info, `Category on class: name ARG'
  2162. ;;     In index: name on class: node. line#.
  2163. ;;
  2164. ;; @defcv category class name         
  2165. ;;     In Info, `Category of class: name'
  2166. ;;     In index: name of class: node. line#.
  2167. ;;
  2168. ;; Specialized object oriented entity:
  2169. ;; @defmethod class name args... 
  2170. ;;     In Info, `Method on class: name ARGS'
  2171. ;;     In index: name on class: node. line#.
  2172. ;;
  2173. ;; @defivar class name
  2174. ;;     In Info, `Instance variable of class: name'
  2175. ;;     In index: name of class: node. line#.
  2176.  
  2177.  
  2178. ;;; The definition formatting functions
  2179.  
  2180. (defun texinfo-format-defun ()
  2181.   (texinfo-push-stack 'defun nil)
  2182.   (setq fill-column (- fill-column 5))
  2183.   (texinfo-format-defun-1 t))
  2184.  
  2185. (defun texinfo-end-defun ()
  2186.   (setq fill-column (+ fill-column 5))
  2187.   (texinfo-discard-command)
  2188.   (let ((start (nth 1 (texinfo-pop-stack 'defun))))
  2189.     (texinfo-do-itemize start)
  2190.     ;; Delete extra newline inserted after header.
  2191.     (save-excursion
  2192.       (goto-char start)
  2193.       (delete-char -1))))
  2194.  
  2195. (defun texinfo-format-defunx ()
  2196.   (texinfo-format-defun-1 nil))
  2197.  
  2198. (defun texinfo-format-defun-1 (first-p)
  2199.   (let ((parse-args (texinfo-format-parse-defun-args))
  2200.         (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type)))
  2201.     (texinfo-discard-command)
  2202.     ;; Delete extra newline inserted after previous header line.
  2203.     (if (not first-p)
  2204.         (delete-char -1))
  2205.     (funcall
  2206.      (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args)
  2207.     ;; Insert extra newline so that paragraph filling does not mess
  2208.     ;; with header line.
  2209.     (insert "\n\n")
  2210.     (rplaca (cdr (cdr (car texinfo-stack))) (point))
  2211.     (funcall
  2212.      (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args)))
  2213.  
  2214. ;;; Formatting the first line of a definition
  2215.  
  2216. ;; @deffn, @defvr, @deftp
  2217. (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2218. (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2219. (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2220. (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2221. (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2222. (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn)
  2223. (defun texinfo-format-deffn (parsed-args)
  2224.   ;; Generalized function-like, variable-like, or generic data-type entity:
  2225.   ;; @deffn category name args...
  2226.   ;;     In Info, `Category: name ARGS'
  2227.   ;; @deftp category name attributes...
  2228.   ;; `category name attributes...'       Note: @deftp args in lower case.
  2229.   (let ((category (car parsed-args))
  2230.         (name (car (cdr parsed-args)))
  2231.         (args (cdr (cdr parsed-args))))
  2232.     (insert " -- " category ": " name)
  2233.     (while args
  2234.       (insert " "
  2235.               (if (or (= ?& (aref (car args) 0))
  2236.                       (eq (eval (car texinfo-defun-type)) 'deftp-type))
  2237.                   (car args)
  2238.                 (upcase (car args))))
  2239.       (setq args (cdr args)))))
  2240.  
  2241. ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple
  2242. (put 'defun 'texinfo-deffn-formatting-property
  2243.      'texinfo-format-specialized-defun)
  2244. (put 'defunx 'texinfo-deffn-formatting-property
  2245.      'texinfo-format-specialized-defun)
  2246. (put 'defmac 'texinfo-deffn-formatting-property
  2247.      'texinfo-format-specialized-defun)
  2248. (put 'defmacx 'texinfo-deffn-formatting-property
  2249.      'texinfo-format-specialized-defun)
  2250. (put 'defspec 'texinfo-deffn-formatting-property
  2251.      'texinfo-format-specialized-defun)
  2252. (put 'defspecx 'texinfo-deffn-formatting-property
  2253.      'texinfo-format-specialized-defun)
  2254. (put 'defvar 'texinfo-deffn-formatting-property
  2255.      'texinfo-format-specialized-defun)
  2256. (put 'defvarx 'texinfo-deffn-formatting-property
  2257.      'texinfo-format-specialized-defun)
  2258. (put 'defopt 'texinfo-deffn-formatting-property
  2259.      'texinfo-format-specialized-defun)
  2260. (put 'defoptx 'texinfo-deffn-formatting-property
  2261.      'texinfo-format-specialized-defun)
  2262. (defun texinfo-format-specialized-defun (parsed-args)
  2263.   ;; Specialized function-like or variable-like entity:
  2264.   ;; @defun name args           In Info, `Function: Name ARGS'
  2265.   ;; @defmac name args          In Info, `Macro: Name ARGS'
  2266.   ;; @defvar name               In Info, `Variable: Name'
  2267.   ;; Use cdr of texinfo-defun-type to determine category:
  2268.   (let ((category (car (cdr texinfo-defun-type)))
  2269.         (name (car parsed-args))
  2270.         (args (cdr parsed-args)))
  2271.     (insert " -- " category ": " name)
  2272.     (while args
  2273.       (insert " "
  2274.               (if (= ?& (aref (car args) 0))
  2275.                   (car args)
  2276.                 (upcase (car args))))
  2277.       (setq args (cdr args)))))
  2278.  
  2279. ;; @deftypefn, @deftypevr: Generalized typed
  2280. (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
  2281. (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
  2282. (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
  2283. (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn)
  2284. (defun texinfo-format-deftypefn (parsed-args)
  2285.   ;; Generalized typed-function-like or typed-variable-like entity:
  2286.   ;; @deftypefn category data-type name args...
  2287.   ;;     In Info, `Category:  data-type name args...'
  2288.   ;; @deftypevr category data-type name 
  2289.   ;;     In Info, `Category:  data-type name'
  2290.   ;; Note: args in lower case, unless modified in command line.
  2291.   (let ((category (car parsed-args))
  2292.         (data-type (car (cdr parsed-args)))
  2293.         (name (car (cdr (cdr parsed-args))))
  2294.         (args (cdr (cdr (cdr parsed-args)))))
  2295.     (insert " -- " category ": " data-type " " name)
  2296.     (while args
  2297.       (insert " " (car args))
  2298.       (setq args (cdr args)))))
  2299.  
  2300. ;; @deftypefun, @deftypevar: Specialized typed
  2301. (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
  2302. (put 'deftypefunx 'texinfo-deffn-formatting-property
  2303.      'texinfo-format-deftypefun)
  2304. (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun)
  2305. (put 'deftypevarx 'texinfo-deffn-formatting-property
  2306.      'texinfo-format-deftypefun)
  2307. (defun texinfo-format-deftypefun (parsed-args)
  2308.   ;; Specialized typed-function-like or typed-variable-like entity:
  2309.   ;; @deftypefun data-type name args...
  2310.   ;;     In Info, `Function:  data-type name ARGS'
  2311.   ;; @deftypevar data-type name 
  2312.   ;;     In Info, `Variable:  data-type name'
  2313.   ;; Note: args in lower case, unless modified in command line.
  2314.   ;; Use cdr of texinfo-defun-type to determine category:
  2315.   (let ((category (car (cdr texinfo-defun-type)))
  2316.         (data-type (car parsed-args))
  2317.         (name (car (cdr  parsed-args)))
  2318.         (args (cdr (cdr parsed-args))))
  2319.     (insert " -- " category ": " data-type " " name)
  2320.     (while args
  2321.       (insert " " (car args))
  2322.       (setq args (cdr args)))))
  2323.  
  2324. ;; @defop: Generalized object-oriented
  2325. (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop)
  2326. (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop)
  2327. (defun texinfo-format-defop (parsed-args)
  2328.   ;; Generalized object oriented entity: 
  2329.   ;; @defop category class name args...
  2330.   ;;     In Info, `Category on class: name ARG'
  2331.   ;; Note: args in upper case; use of `on'
  2332.   (let ((category (car parsed-args))
  2333.         (class (car (cdr parsed-args)))
  2334.         (name (car (cdr (cdr parsed-args))))
  2335.         (args (cdr (cdr (cdr parsed-args)))))
  2336.     (insert " -- " category " on " class ": " name)
  2337.     (while args
  2338.       (insert " " (upcase (car args)))
  2339.       (setq args (cdr args)))))
  2340.  
  2341. ;; @defcv: Generalized object-oriented
  2342. (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
  2343. (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv)
  2344. (defun texinfo-format-defcv (parsed-args)
  2345.   ;; Generalized object oriented entity: 
  2346.   ;; @defcv category class name         
  2347.   ;;     In Info, `Category of class: name'
  2348.   ;; Note: args in upper case; use of `of'
  2349.   (let ((category (car parsed-args))
  2350.         (class (car (cdr parsed-args)))
  2351.         (name (car (cdr (cdr parsed-args))))
  2352.         (args (cdr (cdr (cdr parsed-args)))))
  2353.     (insert " -- " category " of " class ": " name)
  2354.     (while args
  2355.       (insert " " (upcase (car args)))
  2356.       (setq args (cdr args)))))
  2357.  
  2358. ;; @defmethod: Specialized object-oriented
  2359. (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
  2360. (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod)
  2361. (defun texinfo-format-defmethod (parsed-args)
  2362.   ;; Specialized object oriented entity:
  2363.   ;; @defmethod class name args... 
  2364.   ;;     In Info, `Method on class: name ARGS'
  2365.   ;; Note: args in upper case; use of `on'
  2366.   ;; Use cdr of texinfo-defun-type to determine category:
  2367.   (let ((category (car (cdr texinfo-defun-type)))
  2368.         (class (car parsed-args))
  2369.         (name (car (cdr  parsed-args)))
  2370.         (args (cdr  (cdr parsed-args))))
  2371.     (insert " -- " category " on " class ": " name)
  2372.     (while args
  2373.       (insert " " (upcase (car args)))
  2374.       (setq args (cdr args)))))
  2375.  
  2376. ;; @defivar: Specialized object-oriented
  2377. (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
  2378. (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar)
  2379. (defun texinfo-format-defivar (parsed-args)
  2380.   ;; Specialized object oriented entity:
  2381.   ;; @defivar class name
  2382.   ;;     In Info, `Instance variable of class: name'
  2383.   ;; Note: args in upper case; use of `of'
  2384.   ;; Use cdr of texinfo-defun-type to determine category:
  2385.   (let ((category (car (cdr texinfo-defun-type)))
  2386.         (class (car parsed-args))
  2387.         (name (car (cdr  parsed-args)))
  2388.         (args (cdr  (cdr parsed-args))))
  2389.     (insert " -- " category " of " class ": " name)
  2390.     (while args
  2391.       (insert " " (upcase (car args)))
  2392.       (setq args (cdr args)))))
  2393.  
  2394.  
  2395. ;;; Indexing for definitions
  2396.  
  2397. ;; An index entry has three parts: the `entry proper', the node name, and the
  2398. ;; line number.  Depending on the which command is used, the entry is
  2399. ;; formatted differently:
  2400. ;;
  2401. ;; @defun, 
  2402. ;; @defmac, 
  2403. ;; @defspec, 
  2404. ;; @defvar, 
  2405. ;; @defopt          all use their 1st argument as the entry-proper 
  2406. ;;
  2407. ;; @deffn, 
  2408. ;; @defvr, 
  2409. ;; @deftp 
  2410. ;; @deftypefun
  2411. ;; @deftypevar      all use their 2nd argument as the entry-proper
  2412. ;;
  2413. ;; @deftypefn, 
  2414. ;; @deftypevr       both use their 3rd argument as the entry-proper  
  2415. ;;
  2416. ;; @defmethod       uses its 2nd and 1st arguments as an entry-proper 
  2417. ;;                    formatted: NAME on CLASS
  2418.  
  2419. ;; @defop           uses its 3rd and 2nd arguments as an entry-proper 
  2420. ;;                    formatted: NAME on CLASS
  2421. ;;        
  2422. ;; @defivar         uses its 2nd and 1st arguments as an entry-proper
  2423. ;;                    formatted: NAME of CLASS
  2424. ;;
  2425. ;; @defcv           uses its 3rd and 2nd argument as an entry-proper
  2426. ;;                    formatted: NAME of CLASS
  2427.  
  2428. (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2429. (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2430. (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2431. (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2432. (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2433. (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2434. (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2435. (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun)
  2436. (put 'defopt  'texinfo-defun-indexing-property 'texinfo-index-defun)
  2437. (put 'defoptx  'texinfo-defun-indexing-property 'texinfo-index-defun)
  2438. (defun texinfo-index-defun (parsed-args)
  2439.   ;; use 1st parsed-arg  as entry-proper
  2440.   ;; `index-list' will be texinfo-findex or the like
  2441.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2442.     (set index-list
  2443.          (cons 
  2444.           ;; Three elements: entry-proper, node-name, line-number
  2445.           (list
  2446.            (car parsed-args)
  2447.            texinfo-last-node
  2448.            ;; Region formatting may not provide last node position.
  2449.            (if texinfo-last-node-pos
  2450.                (1+ (count-lines texinfo-last-node-pos (point)))
  2451.              1))
  2452.           (symbol-value index-list)))))
  2453.  
  2454. (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2455. (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2456. (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2457. (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2458. (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2459. (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2460. (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2461. (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2462. (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2463. (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn)
  2464. (defun texinfo-index-deffn (parsed-args) 
  2465.  ;; use 2nd parsed-arg  as entry-proper
  2466.   ;; `index-list' will be texinfo-findex or the like
  2467.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2468.     (set index-list
  2469.          (cons 
  2470.           ;; Three elements: entry-proper, node-name, line-number
  2471.           (list
  2472.            (car (cdr parsed-args))
  2473.            texinfo-last-node
  2474.            ;; Region formatting may not provide last node position.
  2475.            (if texinfo-last-node-pos
  2476.                (1+ (count-lines texinfo-last-node-pos (point)))
  2477.              1))
  2478.           (symbol-value index-list)))))
  2479.  
  2480. (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
  2481. (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
  2482. (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
  2483. (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn)
  2484. (defun texinfo-index-deftypefn (parsed-args)
  2485.   ;; use 3rd parsed-arg  as entry-proper
  2486.   ;; `index-list' will be texinfo-findex or the like
  2487.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2488.     (set index-list
  2489.          (cons 
  2490.           ;; Three elements: entry-proper, node-name, line-number
  2491.           (list
  2492.            (car (cdr (cdr parsed-args)))
  2493.            texinfo-last-node
  2494.            ;; Region formatting may not provide last node position.
  2495.            (if texinfo-last-node-pos
  2496.                (1+ (count-lines texinfo-last-node-pos (point)))
  2497.              1))
  2498.           (symbol-value index-list)))))
  2499.  
  2500. (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
  2501. (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod)
  2502. (defun texinfo-index-defmethod (parsed-args)
  2503.   ;; use 2nd on 1st parsed-arg  as entry-proper
  2504.   ;; `index-list' will be texinfo-findex or the like
  2505.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2506.     (set index-list
  2507.          (cons 
  2508.           ;; Three elements: entry-proper, node-name, line-number
  2509.           (list
  2510.            (format "%s on %s"            
  2511.                    (car (cdr parsed-args))
  2512.                    (car parsed-args))
  2513.            texinfo-last-node
  2514.            ;; Region formatting may not provide last node position.
  2515.            (if texinfo-last-node-pos
  2516.                (1+ (count-lines texinfo-last-node-pos (point)))
  2517.              1))
  2518.           (symbol-value index-list)))))
  2519.  
  2520. (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop)
  2521. (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop)
  2522. (defun texinfo-index-defop (parsed-args)
  2523.   ;; use 3rd on 2nd parsed-arg  as entry-proper
  2524.   ;; `index-list' will be texinfo-findex or the like
  2525.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2526.     (set index-list
  2527.          (cons 
  2528.           ;; Three elements: entry-proper, node-name, line-number
  2529.           (list
  2530.            (format "%s on %s"            
  2531.                    (car (cdr (cdr parsed-args)))
  2532.                    (car (cdr parsed-args)))
  2533.            texinfo-last-node
  2534.            ;; Region formatting may not provide last node position.
  2535.            (if texinfo-last-node-pos
  2536.                (1+ (count-lines texinfo-last-node-pos (point)))
  2537.              1))
  2538.           (symbol-value index-list)))))
  2539.  
  2540. (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar)
  2541. (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar)
  2542. (defun texinfo-index-defivar (parsed-args)
  2543.   ;; use 2nd of 1st parsed-arg  as entry-proper
  2544.   ;; `index-list' will be texinfo-findex or the like
  2545.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2546.     (set index-list
  2547.          (cons 
  2548.           ;; Three elements: entry-proper, node-name, line-number
  2549.           (list
  2550.            (format "%s of %s"            
  2551.                    (car (cdr parsed-args))
  2552.                    (car parsed-args))
  2553.            texinfo-last-node
  2554.            ;; Region formatting may not provide last node position.
  2555.            (if texinfo-last-node-pos
  2556.                (1+ (count-lines texinfo-last-node-pos (point)))
  2557.              1))
  2558.           (symbol-value index-list)))))
  2559.  
  2560. (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv)
  2561. (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv)
  2562. (defun texinfo-index-defcv (parsed-args)
  2563.   ;; use 3rd of 2nd parsed-arg  as entry-proper
  2564.   ;; `index-list' will be texinfo-findex or the like
  2565.   (let ((index-list (get texinfo-command-name 'texinfo-defun-index)))
  2566.     (set index-list
  2567.          (cons 
  2568.           ;; Three elements: entry-proper, node-name, line-number
  2569.           (list
  2570.            (format "%s of %s"            
  2571.                    (car (cdr (cdr parsed-args)))
  2572.                    (car (cdr parsed-args)))
  2573.            texinfo-last-node
  2574.            ;; Region formatting may not provide last node position.
  2575.            (if texinfo-last-node-pos
  2576.                (1+ (count-lines texinfo-last-node-pos (point)))
  2577.              1))
  2578.           (symbol-value index-list)))))
  2579.  
  2580.  
  2581. ;;; Properties for definitions
  2582.  
  2583. ;; Each definition command has six properties:
  2584. ;;
  2585. ;; 1. texinfo-deffn-formatting-property      to format definition line
  2586. ;; 2. texinfo-defun-indexing-property        to create index entry
  2587. ;; 3. texinfo-format                         formatting command
  2588. ;; 4. texinfo-end                            end formatting command
  2589. ;; 5. texinfo-defun-type                     type of deffn to format
  2590. ;; 6. texinfo-defun-index                    type of index to use
  2591. ;;
  2592. ;; The `x' forms of each definition command are used for the second
  2593. ;; and subsequent header lines.
  2594.  
  2595. ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property
  2596. ;; are listed just before the appropriate formatting and indexing commands.
  2597.  
  2598. (put 'deffn 'texinfo-format 'texinfo-format-defun)
  2599. (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
  2600. (put 'deffn 'texinfo-end 'texinfo-end-defun)
  2601. (put 'deffn 'texinfo-defun-type '('deffn-type nil))
  2602. (put 'deffnx 'texinfo-defun-type '('deffn-type nil))
  2603. (put 'deffn 'texinfo-defun-index 'texinfo-findex)
  2604. (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
  2605.  
  2606. (put 'defun 'texinfo-format 'texinfo-format-defun)
  2607. (put 'defunx 'texinfo-format 'texinfo-format-defunx)
  2608. (put 'defun 'texinfo-end 'texinfo-end-defun)
  2609. (put 'defun 'texinfo-defun-type '('defun-type "Function"))
  2610. (put 'defunx 'texinfo-defun-type '('defun-type "Function"))
  2611. (put 'defun 'texinfo-defun-index 'texinfo-findex)
  2612. (put 'defunx 'texinfo-defun-index 'texinfo-findex)
  2613.  
  2614. (put 'defmac 'texinfo-format 'texinfo-format-defun)
  2615. (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
  2616. (put 'defmac 'texinfo-end 'texinfo-end-defun)
  2617. (put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
  2618. (put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
  2619. (put 'defmac 'texinfo-defun-index 'texinfo-findex)
  2620. (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
  2621.  
  2622. (put 'defspec 'texinfo-format 'texinfo-format-defun)
  2623. (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
  2624. (put 'defspec 'texinfo-end 'texinfo-end-defun)
  2625. (put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
  2626. (put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
  2627. (put 'defspec 'texinfo-defun-index 'texinfo-findex)
  2628. (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
  2629.  
  2630. (put 'defvr 'texinfo-format 'texinfo-format-defun)
  2631. (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
  2632. (put 'defvr 'texinfo-end 'texinfo-end-defun)
  2633. (put 'defvr 'texinfo-defun-type '('deffn-type nil))
  2634. (put 'defvrx 'texinfo-defun-type '('deffn-type nil))
  2635. (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
  2636. (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
  2637.  
  2638. (put 'defvar 'texinfo-format 'texinfo-format-defun)
  2639. (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
  2640. (put 'defvar 'texinfo-end 'texinfo-end-defun)
  2641. (put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
  2642. (put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
  2643. (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
  2644. (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
  2645.  
  2646. (put 'defconst 'texinfo-format 'texinfo-format-defun)
  2647. (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
  2648. (put 'defconst 'texinfo-end 'texinfo-end-defun)
  2649. (put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
  2650. (put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
  2651. (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
  2652. (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
  2653.  
  2654. (put 'defcmd 'texinfo-format 'texinfo-format-defun)
  2655. (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
  2656. (put 'defcmd 'texinfo-end 'texinfo-end-defun)
  2657. (put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
  2658. (put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
  2659. (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
  2660. (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
  2661.  
  2662. (put 'defopt 'texinfo-format 'texinfo-format-defun)
  2663. (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
  2664. (put 'defopt 'texinfo-end 'texinfo-end-defun)
  2665. (put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
  2666. (put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
  2667. (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
  2668. (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
  2669.  
  2670. (put 'deftp 'texinfo-format 'texinfo-format-defun)
  2671. (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
  2672. (put 'deftp 'texinfo-end 'texinfo-end-defun)
  2673. (put 'deftp 'texinfo-defun-type '('deftp-type nil))
  2674. (put 'deftpx 'texinfo-defun-type '('deftp-type nil))
  2675. (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
  2676. (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
  2677.  
  2678. ;;; Object-oriented stuff is a little hairier.
  2679.  
  2680. (put 'defop 'texinfo-format 'texinfo-format-defun)
  2681. (put 'defopx 'texinfo-format 'texinfo-format-defunx)
  2682. (put 'defop 'texinfo-end 'texinfo-end-defun)
  2683. (put 'defop 'texinfo-defun-type '('defop-type nil))
  2684. (put 'defopx 'texinfo-defun-type '('defop-type nil))
  2685. (put 'defop 'texinfo-defun-index 'texinfo-findex)
  2686. (put 'defopx 'texinfo-defun-index 'texinfo-findex)
  2687.  
  2688. (put 'defmethod 'texinfo-format 'texinfo-format-defun)
  2689. (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
  2690. (put 'defmethod 'texinfo-end 'texinfo-end-defun)
  2691. (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
  2692. (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
  2693. (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
  2694. (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
  2695.  
  2696. (put 'defcv 'texinfo-format 'texinfo-format-defun)
  2697. (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
  2698. (put 'defcv 'texinfo-end 'texinfo-end-defun)
  2699. (put 'defcv 'texinfo-defun-type '('defop-type nil))
  2700. (put 'defcvx 'texinfo-defun-type '('defop-type nil))
  2701. (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
  2702. (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
  2703.  
  2704. (put 'defivar 'texinfo-format 'texinfo-format-defun)
  2705. (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
  2706. (put 'defivar 'texinfo-end 'texinfo-end-defun)
  2707. (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
  2708. (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
  2709. (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
  2710. (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
  2711.  
  2712. ;;; Typed functions and variables
  2713.  
  2714. (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
  2715. (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
  2716. (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
  2717. (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
  2718. (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
  2719. (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
  2720. (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
  2721.  
  2722. (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
  2723. (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
  2724. (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
  2725. (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
  2726. (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
  2727. (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
  2728. (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
  2729.  
  2730. (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
  2731. (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
  2732. (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
  2733. (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
  2734. (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
  2735. (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
  2736. (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
  2737.  
  2738. (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
  2739. (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
  2740. (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
  2741. (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
  2742. (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
  2743. (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
  2744. (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
  2745.  
  2746.  
  2747. ;;; @set, @clear, @ifset, @ifclear
  2748.  
  2749. ;; If a flag is set with @set FLAG, then text between @ifset and @end
  2750. ;; ifset is formatted normally, but if the flag is is cleared with
  2751. ;; @clear FLAG, then the text is not formatted; it is ignored.
  2752.  
  2753. ;; If a flag is cleared with @clear FLAG, then text between @ifclear
  2754. ;; and @end ifclear is formatted normally, but if the flag is is set with
  2755. ;; @set FLAG, then the text is not formatted; it is ignored.  @ifclear
  2756. ;; is the opposite of @ifset.
  2757.  
  2758. ;; If a flag is set to a string with @set FLAG, 
  2759. ;; replace  @value{FLAG} with the string.
  2760. ;; If a flag with a value is cleared, 
  2761. ;; @value{FLAG} is invalid, 
  2762. ;; as if there had never been any @set FLAG previously.
  2763.  
  2764. (put 'clear 'texinfo-format 'texinfo-clear)
  2765. (defun texinfo-clear ()
  2766.   "Clear the value of the flag."
  2767.   (let* ((arg (texinfo-parse-arg-discard))
  2768.          (flag (car (read-from-string arg)))
  2769.          (value (substring arg (cdr (read-from-string arg)))))
  2770.     (put flag 'texinfo-whether-setp 'flag-cleared)
  2771.     (put flag 'texinfo-set-value "")))
  2772.  
  2773. (put 'set 'texinfo-format 'texinfo-set)
  2774. (defun texinfo-set ()
  2775.   "Set the value of the flag, optionally to a string.
  2776. The command  `@set foo This is a string.'
  2777. sets flag foo to the value: `This is a string.'
  2778. The command  `@value{foo}'  expands to the value."
  2779.   (let* ((arg (texinfo-parse-arg-discard))
  2780.          (flag (car (read-from-string arg)))
  2781.          (value (substring arg (cdr (read-from-string arg)))))
  2782.     (put flag 'texinfo-whether-setp 'flag-set)
  2783.     (put flag 'texinfo-set-value value)))
  2784.  
  2785. (put 'value 'texinfo-format 'texinfo-value)
  2786. (defun texinfo-value ()
  2787.   "Insert the string to which the flag is set.
  2788. The command  `@set foo This is a string.'
  2789. sets flag foo to the value: `This is a string.'
  2790. The command  `@value{foo}'  expands to the value."
  2791.   (let ((arg (texinfo-parse-arg-discard)))
  2792.     (cond ((and
  2793.             (eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2794.                 'flag-set)
  2795.             (get (car (read-from-string arg)) 'texinfo-set-value))
  2796.            (insert (get (car (read-from-string arg)) 'texinfo-set-value)))
  2797.           ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) 
  2798.                'flag-cleared)
  2799.            (insert (format "{No value for \"%s\"}"  arg)))
  2800.           ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil)
  2801.            (insert (format "{No value for \"%s\"}"  arg))))))
  2802.  
  2803. (put 'ifset 'texinfo-end 'texinfo-discard-command)
  2804. (put 'ifset 'texinfo-format 'texinfo-if-set)
  2805. (defun texinfo-if-set ()
  2806.   "If set, continue formatting; else do not format region up to @end ifset"
  2807.   (let ((arg (texinfo-parse-arg-discard)))
  2808.     (cond
  2809.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2810.           'flag-set)
  2811.       ;; Format the text (i.e., do not remove it); do nothing here.
  2812.       ())
  2813.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2814.           'flag-cleared)
  2815.       ;; Clear region (i.e., cause the text to be ignored).
  2816.       (delete-region texinfo-command-start
  2817.                        (progn (re-search-forward "@end ifset[ \t]*\n")
  2818.                               (point))))
  2819.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2820.           nil)
  2821.       ;; In this case flag is neither set nor cleared.  
  2822.       ;; Act as if set, i.e. do nothing.
  2823.       ()))))
  2824.  
  2825. (put 'ifclear 'texinfo-end 'texinfo-discard-command)
  2826. (put 'ifclear 'texinfo-format 'texinfo-if-clear)
  2827. (defun texinfo-if-clear ()
  2828.   "If clear, continue formatting; if set, do not format up to @end ifset"
  2829.   (let ((arg (texinfo-parse-arg-discard)))
  2830.     (cond
  2831.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2832.           'flag-set)
  2833.       ;; Clear region (i.e., cause the text to be ignored).
  2834.       (delete-region texinfo-command-start
  2835.                        (progn (re-search-forward "@end ifclear[ \t]*\n")
  2836.                               (point))))
  2837.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2838.           'flag-cleared)
  2839.       ;; Format the text (i.e., do not remove it); do nothing here.
  2840.       ())
  2841.      ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp)
  2842.           nil)
  2843.       ;; In this case flag is neither set nor cleared.  
  2844.       ;; Act as if clear, i.e. do nothing.
  2845.       ()))))
  2846.  
  2847.  
  2848. ;;; Process included files:  `@include' command
  2849.  
  2850. ;; Updated 19 October 1990
  2851. ;; In the original version, include files were ignored by Info but
  2852. ;; incorporated in to the printed manual.  To make references to the
  2853. ;; included file, the Texinfo source file has to refer to the included
  2854. ;; files using the `(filename)nodename' format for refering to other
  2855. ;; Info files.  Also, the included files had to be formatted on their
  2856. ;; own.  It was just like they were another file.
  2857.  
  2858. ;; Currently, include files are inserted into the buffer that is
  2859. ;; formatted for Info.  If large, the resulting info file is split and
  2860. ;; tagified.  For current include files to work, the master menu must
  2861. ;; refer to all the nodes, and the highest level nodes in the include
  2862. ;; files must have the correct next, prev, and up pointers.
  2863.  
  2864. ;; The included file may have an @setfilename and even an @settitle,
  2865. ;; but not an `\input texinfo' line.
  2866.  
  2867. ;; Updated 24 March 1993
  2868. ;; In order for @raisesections and @lowersections to work, included
  2869. ;; files must be inserted into the buffer holding the outer file
  2870. ;; before other Info formatting takes place.  So @include is no longer
  2871. ;; is treated like other @-commands.
  2872. (put 'include 'texinfo-format  'texinfo-format-noop)
  2873.  
  2874. ; Original definition:
  2875. ; (defun texinfo-format-include ()
  2876. ;   (let ((filename (texinfo-parse-arg-discard))
  2877. ;       (default-directory input-directory)
  2878. ;       subindex)
  2879. ;     (setq subindex
  2880. ;         (save-excursion
  2881. ;           (progn (find-file
  2882. ;                   (cond ((file-readable-p (concat filename ".texinfo"))
  2883. ;                          (concat filename ".texinfo"))
  2884. ;                         ((file-readable-p (concat filename ".texi"))
  2885. ;                          (concat filename ".texi"))
  2886. ;                         ((file-readable-p (concat filename ".tex"))
  2887. ;                          (concat filename ".tex"))
  2888. ;                         ((file-readable-p filename)
  2889. ;                          filename)
  2890. ;                         (t (error "@include'd file %s not found"
  2891. ;                                   filename))))
  2892. ;                  (texinfo-format-buffer-1))))
  2893. ;     (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex))
  2894. ;     (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex))
  2895. ;     (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex))
  2896. ;     (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex))
  2897. ;     (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex))
  2898. ;     (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex))))
  2899. ;
  2900. ;(defun texinfo-subindex (indexvar file content)
  2901. ;  (set indexvar (cons (list 'recurse file content)
  2902. ;                      (symbol-value indexvar))))
  2903.  
  2904. ; Second definition:
  2905. ; (put 'include 'texinfo-format 'texinfo-format-include)
  2906. ; (defun texinfo-format-include ()
  2907. ;   (let ((filename (concat input-directory
  2908. ;                           (texinfo-parse-arg-discard)))
  2909. ;         (default-directory input-directory))
  2910. ;     (message "Reading: %s" filename)
  2911. ;     (save-excursion
  2912. ;       (save-restriction
  2913. ;         (narrow-to-region
  2914. ;          (point)
  2915. ;          (+ (point) (car (cdr (insert-file-contents filename)))))
  2916. ;         (goto-char (point-min))
  2917. ;         (texinfo-append-refill)
  2918. ;         (texinfo-format-convert (point-min) (point-max))))
  2919. ;     (setq last-input-buffer input-buffer)  ; to bypass setfilename
  2920. ;     ))
  2921.  
  2922.  
  2923. ;;; Numerous commands do nothing in Texinfo
  2924.  
  2925. ;; These commands are defined in texinfo.tex for printed output.
  2926.  
  2927. (put 'bye 'texinfo-format 'texinfo-discard-line)
  2928. (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
  2929. (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
  2930. (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
  2931. (put 'finalout 'texinfo-format 'texinfo-discard-line)
  2932. (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
  2933. (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
  2934. (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
  2935. (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
  2936. (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
  2937. (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
  2938. (put 'need 'texinfo-format 'texinfo-discard-line-with-args)
  2939. (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
  2940. (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
  2941. (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
  2942. (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
  2943. (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
  2944. (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
  2945. (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
  2946. (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args)
  2947. (put 'smallbook 'texinfo-format 'texinfo-discard-line)
  2948. (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
  2949.  
  2950.  
  2951. ;;; Some commands cannot be handled
  2952.  
  2953. (defun texinfo-unsupported ()
  2954.   (error "%s is not handled by texinfo"
  2955.          (buffer-substring texinfo-command-start texinfo-command-end)))
  2956.  
  2957. ;;; Batch formatting
  2958.  
  2959. (defun batch-texinfo-format ()
  2960.   "Runs  texinfo-format-buffer  on the files remaining on the command line.
  2961. Must be used only with -batch, and kills emacs on completion.
  2962. Each file will be processed even if an error occurred previously.
  2963. For example, invoke
  2964.   \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
  2965.   (if (not noninteractive)
  2966.       (error "batch-texinfo-format may only be used -batch."))
  2967.   (let ((version-control t)
  2968.         (auto-save-default nil)
  2969.         (find-file-run-dired nil)
  2970.         (kept-old-versions 259259)
  2971.         (kept-new-versions 259259))
  2972.     (let ((error 0)
  2973.           file
  2974.           (files ()))
  2975.       (while command-line-args-left
  2976.         (setq file (expand-file-name (car command-line-args-left)))
  2977.         (cond ((not (file-exists-p file))
  2978.                (message ">> %s does not exist!" file)
  2979.                (setq error 1
  2980.                      command-line-args-left (cdr command-line-args-left)))
  2981.               ((file-directory-p file)
  2982.                (setq command-line-args-left
  2983.                      (nconc (directory-files file)
  2984.                             (cdr command-line-args-left))))
  2985.               (t
  2986.                (setq files (cons file files)
  2987.                      command-line-args-left (cdr command-line-args-left)))))
  2988.       (while files
  2989.         (setq file (car files)
  2990.               files (cdr files))
  2991.         (condition-case err
  2992.             (progn
  2993.               (if buffer-file-name (kill-buffer (current-buffer)))
  2994.               (find-file file)
  2995.               (buffer-disable-undo (current-buffer))
  2996.               (set-buffer-modified-p nil)
  2997.               (texinfo-mode)
  2998.               (message "texinfo formatting %s..." file)
  2999.               (texinfo-format-buffer nil)
  3000.               (if (buffer-modified-p)
  3001.                   (progn (message "Saving modified %s" (buffer-file-name))
  3002.                          (save-buffer))))
  3003.           (error
  3004.            (message ">> Error: %s" (prin1-to-string err))
  3005.            (message ">>  point at")
  3006.            (let ((s (buffer-substring (point)
  3007.                                       (min (+ (point) 100)
  3008.                                            (point-max))))
  3009.                  (tem 0))
  3010.              (while (setq tem (string-match "\n+" s tem))
  3011.                (setq s (concat (substring s 0 (match-beginning 0))
  3012.                                "\n>>  "
  3013.                                (substring s (match-end 0)))
  3014.                      tem (1+ tem)))
  3015.              (message ">>  %s" s))
  3016.            (setq error 1))))
  3017.       (kill-emacs error))))
  3018.  
  3019.  
  3020. ;;; Place `provide' at end of file.
  3021. (provide 'texinfmt)
  3022.  
  3023. ;;; texinfmt.el ends here.
  3024.